Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #504 from edwin0cheng/fix-win-leak
Browse files Browse the repository at this point in the history
std::auto_ptr will leak for array, using std::vector instead.
  • Loading branch information
nethip committed Mar 16, 2015
2 parents 67b37d7 + 86d53a7 commit 40996c4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions appshell/appshell_extensions_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,16 @@ int32 OpenLiveBrowser(ExtensionString argURL, bool enableRemoteDebugging)

// Args must be mutable
int argsBufSize = args.length() +1;
std::auto_ptr<WCHAR> argsBuf( new WCHAR[argsBufSize]);
wcscpy(argsBuf.get(), args.c_str());
std::vector<WCHAR> argsBuf;
argsBuf.resize(argsBufSize);
wcscpy(&argsBuf[0], args.c_str());

STARTUPINFO si = {0};
si.cb = sizeof(si);
PROCESS_INFORMATION pi = {0};

// Launch cmd.exe and pass in the arguments
if (!CreateProcess(NULL, argsBuf.get(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
if (!CreateProcess(NULL, &argsBuf[0], NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
return ConvertWinErrorCode(GetLastError());
}

Expand Down

0 comments on commit 40996c4

Please sign in to comment.