From c15ead94b00d4673a1ce8b438a510b0cfa2931fd Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja@tarantool.org> Date: Fri, 22 Jun 2012 14:01:49 +0400 Subject: [PATCH] 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. --- third_party/proctitle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/third_party/proctitle.c b/third_party/proctitle.c index 233a55d2e4..92eca759c1 100644 --- a/third_party/proctitle.c +++ b/third_party/proctitle.c @@ -256,10 +256,12 @@ free_proc_title(int argc, char **argv) free(environ[i]); free(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++) free(argv[i]); free(argv); +#endif /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */ } void -- GitLab