Pier Angelo Vendrame pushed to branch tor-browser-153.0a1-16.0-2 at The Tor Project / Applications / Tor Browser
Commits:
-
faea1716
by Pier Angelo Vendrame at 2026-07-13T20:54:32+02:00
1 changed file:
Changes:
| ... | ... | @@ -11,9 +11,9 @@ |
| 11 | 11 | #include "modules/desktop_capture/win/desktop_capture_utils.h"
|
| 12 | 12 | |
| 13 | 13 | #include <string>
|
| 14 | +#include <vector>
|
|
| 14 | 15 | |
| 15 | -#include <cstdio>
|
|
| 16 | -#include <cstdlib>
|
|
| 16 | +#include "rtc_base/strings/string_builder.h"
|
|
| 17 | 17 | #include "stringapiset.h"
|
| 18 | 18 | |
| 19 | 19 | namespace webrtc {
|
| ... | ... | @@ -25,14 +25,18 @@ std::string ComErrorToString(const _com_error& error) { |
| 25 | 25 | webrtc::StringBuilder string_builder;
|
| 26 | 26 | string_builder.AppendFormat("HRESULT: 0x%08X, Message: ", error.Error());
|
| 27 | 27 | #ifdef _UNICODE
|
| 28 | - WideCharToMultiByte(CP_UTF8, 0, error.ErrorMessage(), -1,
|
|
| 29 | - buffer + string_builder.size(),
|
|
| 30 | - sizeof(buffer) - string_builder.size(), nullptr, nullptr);
|
|
| 31 | - buffer[sizeof(buffer) - 1] = 0;
|
|
| 28 | + int size = WideCharToMultiByte(CP_UTF8, 0, error.ErrorMessage(), -1, nullptr,
|
|
| 29 | + 0, nullptr, nullptr);
|
|
| 30 | + if (size > 0) {
|
|
| 31 | + std::vector<char> buffer(static_cast<size_t>(size));
|
|
| 32 | + WideCharToMultiByte(CP_UTF8, 0, error.ErrorMessage(), -1, buffer.data(),
|
|
| 33 | + size, nullptr, nullptr);
|
|
| 34 | + string_builder << buffer.data();
|
|
| 35 | + }
|
|
| 32 | 36 | #else
|
| 33 | 37 | string_builder << error.ErrorMessage();
|
| 34 | 38 | #endif
|
| 35 | - return buffer;
|
|
| 39 | + return string_builder.str();
|
|
| 36 | 40 | }
|
| 37 | 41 | |
| 38 | 42 | } // namespace utils
|