diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 17:48:46 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 17:48:46 +0000 |
commit | a150c7377d8ed3d3bfacdd09f24c6916ea98c01d (patch) | |
tree | c45083122a2a427303e1c9d2bcbdfa9dac5c6c43 /sandbox | |
parent | 5a93bab9e0dfe14c0d068338d8745812cc7271c4 (diff) | |
download | chromium_src-a150c7377d8ed3d3bfacdd09f24c6916ea98c01d.zip chromium_src-a150c7377d8ed3d3bfacdd09f24c6916ea98c01d.tar.gz chromium_src-a150c7377d8ed3d3bfacdd09f24c6916ea98c01d.tar.bz2 |
Declare exe_name and cmd_line as const pointers and use
const_cast only where necessary.
Fix a FORWARD_NULL defect reported by Coverity. Pass
cmd_line to sandbox::WideToMultiByte only if cmd_line
is not NULL.
R=rvargas
BUG=http://crbug.com/17101
TEST=none
Review URL: http://codereview.chromium.org/155969
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sandbox')
-rw-r--r-- | sandbox/src/process_policy_test.cc | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sandbox/src/process_policy_test.cc b/sandbox/src/process_policy_test.cc index e156cc5..0fbf204 100644 --- a/sandbox/src/process_policy_test.cc +++ b/sandbox/src/process_policy_test.cc @@ -37,18 +37,18 @@ sandbox::SboxTestResult CreateProcessHelper(const std::wstring &exe, PROCESS_INFORMATION pi; STARTUPINFOW si = {sizeof(si)}; - wchar_t *exe_name = NULL; + const wchar_t *exe_name = NULL; if (!exe.empty()) - exe_name = const_cast<wchar_t*>(exe.c_str()); + exe_name = exe.c_str(); - wchar_t *cmd_line = NULL; + const wchar_t *cmd_line = NULL; if (!command.empty()) - cmd_line = const_cast<wchar_t*>(command.c_str()); + cmd_line = command.c_str(); // Create the process with the unicode version of the API. sandbox::SboxTestResult ret1 = sandbox::SBOX_TEST_FAILED; - if (!::CreateProcessW(exe_name, cmd_line, NULL, NULL, FALSE, 0, NULL, - NULL, &si, &pi)) { + if (!::CreateProcessW(exe_name, const_cast<wchar_t*>(cmd_line), NULL, NULL, + FALSE, 0, NULL, NULL, &si, &pi)) { DWORD last_error = GetLastError(); if ((ERROR_NOT_ENOUGH_QUOTA == last_error) || (ERROR_ACCESS_DENIED == last_error) || @@ -65,7 +65,9 @@ sandbox::SboxTestResult CreateProcessHelper(const std::wstring &exe, STARTUPINFOA sia = {sizeof(sia)}; sandbox::SboxTestResult ret2 = sandbox::SBOX_TEST_FAILED; - std::string narrow_cmd_line = sandbox::WideToMultiByte(cmd_line); + std::string narrow_cmd_line; + if (cmd_line) + narrow_cmd_line = sandbox::WideToMultiByte(cmd_line); if (!::CreateProcessA( exe_name ? sandbox::WideToMultiByte(exe_name).c_str() : NULL, cmd_line ? const_cast<char*>(narrow_cmd_line.c_str()) : NULL, |