From cfb37e47959ff49abfa16bc4b5783b52e5b84c6f Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 15 Feb 2015 15:54:44 +0800 Subject: [PATCH] std::auto_ptr will leak for array, using std::vector instead. --- appshell/appshell_extensions_win.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/appshell/appshell_extensions_win.cpp b/appshell/appshell_extensions_win.cpp index a6e76cfd4..47f65ab07 100644 --- a/appshell/appshell_extensions_win.cpp +++ b/appshell/appshell_extensions_win.cpp @@ -349,15 +349,16 @@ int32 OpenLiveBrowser(ExtensionString argURL, bool enableRemoteDebugging) // Args must be mutable int argsBufSize = args.length() +1; - std::auto_ptr argsBuf( new WCHAR[argsBufSize]); - wcscpy(argsBuf.get(), args.c_str()); + std::vector 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()); }