diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 22:12:02 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-25 22:12:02 +0000 |
commit | 3ca4214c1790b583dd436a49b7e3aa60a02b4ce7 (patch) | |
tree | c9001aed25377c965c6eee4c0ae20d86d3dffa1a /base | |
parent | ebafa9eb9f57afdeff25b871e4831304c4c5004a (diff) | |
download | chromium_src-3ca4214c1790b583dd436a49b7e3aa60a02b4ce7.zip chromium_src-3ca4214c1790b583dd436a49b7e3aa60a02b4ce7.tar.gz chromium_src-3ca4214c1790b583dd436a49b7e3aa60a02b4ce7.tar.bz2 |
Eliminate precarious use of const_cast<wchar*>(wstring.get())
Review URL: http://codereview.chromium.org/42617
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/logging.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/base/logging.cc b/base/logging.cc index d3e66fd..11dfe5d 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -318,24 +318,23 @@ void DisplayDebugMessage(const std::string& str) { backslash[1] = 0; wcscat_s(prog_name, MAX_PATH, L"debug_message.exe"); - // Stupid CreateProcess requires a non-const command line and may modify it. - // We also want to use the wide string. - std::wstring cmdline_string = base::SysUTF8ToWide(str); - wchar_t* cmdline = const_cast<wchar_t*>(cmdline_string.c_str()); + std::wstring cmdline = base::SysUTF8ToWide(str); + if (cmdline.empty()) + return; STARTUPINFO startup_info; memset(&startup_info, 0, sizeof(startup_info)); startup_info.cb = sizeof(startup_info); PROCESS_INFORMATION process_info; - if (CreateProcessW(prog_name, cmdline, NULL, NULL, false, 0, NULL, + if (CreateProcessW(prog_name, &cmdline[0], NULL, NULL, false, 0, NULL, NULL, &startup_info, &process_info)) { WaitForSingleObject(process_info.hProcess, INFINITE); CloseHandle(process_info.hThread); CloseHandle(process_info.hProcess); } else { // debug process broken, let's just do a message box - MessageBoxW(NULL, cmdline, L"Fatal error", + MessageBoxW(NULL, &cmdline[0], L"Fatal error", MB_OK | MB_ICONHAND | MB_TOPMOST); } #else |