aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-12-31 14:20:21 +0000
committerRon Yorston <rmy@pobox.com>2023-12-31 14:20:21 +0000
commit0c7ddaef584c59c8c00ba5a6d9a426ad4ca61515 (patch)
tree85dd0c39f6524a825db1285f027979af26544882
parent62c3c07d04a8e48ce221fe84fd73e2fefb94c760 (diff)
downloadbusybox-w32-0c7ddaef584c59c8c00ba5a6d9a426ad4ca61515.tar.gz
busybox-w32-0c7ddaef584c59c8c00ba5a6d9a426ad4ca61515.tar.bz2
busybox-w32-0c7ddaef584c59c8c00ba5a6d9a426ad4ca61515.zip
httpd: consistently leak memory, or not
create_detached_process() is only used when running a CGI script. Previously it leaked the return values from quote_arg() but freed the command line it built. Whether or not the CGI script is successfully run its parent process exits almost immediately, so there's no pressing need to free the memory. If FEATURE_CLEAN_UP is disabled (which it is by default) don't bother. Saves 16 bytes.
-rw-r--r--win32/process.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/win32/process.c b/win32/process.c
index 35480e08d..f001ef35a 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -259,8 +259,12 @@ create_detached_process(const char *prog, char *const *argv)
259 int success; 259 int success;
260 260
261 argc = string_array_len((char **)argv); 261 argc = string_array_len((char **)argv);
262 for (i = 0; i < argc; i++) 262 for (i = 0; i < argc; i++) {
263 command = xappendword(command, quote_arg(argv[i])); 263 char *qarg = quote_arg(argv[i]);
264 command = xappendword(command, qarg);
265 if (ENABLE_FEATURE_CLEAN_UP)
266 free(qarg);
267 }
264 268
265 ZeroMemory(&siStartInfo, sizeof(STARTUPINFO)); 269 ZeroMemory(&siStartInfo, sizeof(STARTUPINFO));
266 siStartInfo.cb = sizeof(STARTUPINFO); 270 siStartInfo.cb = sizeof(STARTUPINFO);
@@ -279,7 +283,8 @@ create_detached_process(const char *prog, char *const *argv)
279 &siStartInfo, /* STARTUPINFO pointer */ 283 &siStartInfo, /* STARTUPINFO pointer */
280 &piProcInfo); /* receives PROCESS_INFORMATION */ 284 &piProcInfo); /* receives PROCESS_INFORMATION */
281 285
282 free(command); 286 if (ENABLE_FEATURE_CLEAN_UP)
287 free(command);
283 288
284 if (!success) 289 if (!success)
285 return -1; 290 return -1;