Skip to content
Snippets Groups Projects
Commit c15ead94 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

MacOS X port: do not free argv if it was not allocated.

Darwin revealed a bug in our free_proc_title() function, which was
added to procitle.c to work well with valgrind: we free argv pointer
even if it wasn't allocated (none of PS_USE_CLOBBER_ARGV/PS_USE_CHANGE_ARGV
was set).

Don't free memory if it wasn't allocated.

Another issue is understanding why Darwin doesn't define
PS_USE_SETPROCTITLE and why our FreeBSD port didn't hit this bug.
parent 0faba1c1
No related branches found
No related tags found
No related merge requests found
...@@ -256,10 +256,12 @@ free_proc_title(int argc, char **argv) ...@@ -256,10 +256,12 @@ free_proc_title(int argc, char **argv)
free(environ[i]); free(environ[i]);
free(environ); free(environ);
environ = save_environ; environ = save_environ;
#endif #endif /* PS_USE_CLOBBER_ARGV */
#if defined(PS_USE_CHANGE_ARGV) || defined(PS_USE_CLOBBER_ARGV)
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
free(argv[i]); free(argv[i]);
free(argv); free(argv);
#endif /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */
} }
void void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment