From 800920c4b37502e59927464c05c9ca65db0390e3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 10 Dec 2020 23:43:20 +0100 Subject: execute, spawn-pipe: Fix memory leak on native Windows. * lib/windows-spawn.h (prepare_spawn): Add a second parameter. * lib/windows-spawn.c: Don't include xalloc.h. (quoted_arg_length, quoted_arg_string): New functions, extracted from prepare_spawn. (prepare_spawn): Use malloc instead of XNMALLOC. Allocate memory for all elements of *new_argv together. * modules/windows-spawn (Depends-on): Remove xalloc. Add malloc-posix. * lib/os2-spawn.h (prepare_spawn): Add a second parameter. * lib/os2-spawn.c: Don't include xalloc.h. (prepare_spawn): Use malloc instead of XNMALLOC. Allocate memory for all elements of *new_argv together. * lib/execute.c: Include xalloc.h. (execute): Check return value of prepare_spawn. Free the memory allocated by prepare_spawn. * modules/execute (Depends-on): Add xalloc-die. * lib/spawn-pipe.c: Include xalloc.h. (create_pipe): Check return value of prepare_spawn. Free the memory allocated by prepare_spawn. * modules/spawn-pipe (Depends-on): Add xalloc-die. --- lib/os2-spawn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/os2-spawn.h') diff --git a/lib/os2-spawn.h b/lib/os2-spawn.h index 701cc10c5e..4c8c6a89fd 100644 --- a/lib/os2-spawn.h +++ b/lib/os2-spawn.h @@ -27,6 +27,6 @@ extern int dup_safer_noinherit (int fd); extern void undup_safer_noinherit (int tempfd, int origfd); /* Prepares an argument vector before calling spawn(). */ -extern char ** prepare_spawn (char **argv); +extern char ** prepare_spawn (char **argv, char **mem_to_free); #endif /* _OS2_SPAWN_H */ -- cgit v1.2.1