Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Unified Diff: sync/util/get_session_name_win.cc

Issue 479703004: Ensure syncer::internal::GetComputerName returns a UTF-8 string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use the returned size instead of wcslen(). Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/util/get_session_name.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/util/get_session_name_win.cc
diff --git a/sync/util/get_session_name_win.cc b/sync/util/get_session_name_win.cc
index 101bcd4fea7c0a41a34799a899222076cd43253d..58980a3ac069f5f0dd09946e7d1adb63224a16db 100644
--- a/sync/util/get_session_name_win.cc
+++ b/sync/util/get_session_name_win.cc
@@ -4,16 +4,24 @@
#include "sync/util/get_session_name_win.h"
+#include "base/logging.h"
Nicolas Zea 2014/08/28 18:58:29 nit: can remove this?
maniscalco 2014/08/28 19:10:58 We need it since it's where DCHECK comes from.
+#include "base/macros.h"
+#include "base/strings/utf_string_conversions.h"
+
#include <windows.h>
namespace syncer {
namespace internal {
std::string GetComputerName() {
- char computer_name[MAX_COMPUTERNAME_LENGTH + 1];
- DWORD size = sizeof(computer_name);
- if (GetComputerNameA(computer_name, &size))
- return computer_name;
+ wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
+ DWORD size = arraysize(computer_name);
+ if (::GetComputerNameW(computer_name, &size)) {
+ std::string result;
+ bool conversion_successful = base::WideToUTF8(computer_name, size, &result);
+ DCHECK(conversion_successful);
+ return result;
+ }
return std::string();
}
« no previous file with comments | « sync/util/get_session_name.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698