Patch for GetCommandForPid() in osdep_darwin.c
commita98680cd149606210f776eb68d02cecfc69e61e2
authorDiedrich Vorberg <diedrich@tux4web.de>
Mon, 19 Oct 2020 19:38:29 +0000 (19 20:38 +0100)
committerCarlos R. Mafra <crmafra@gmail.com>
Mon, 19 Oct 2020 19:38:29 +0000 (19 20:38 +0100)
tree5d59efd2bfae6ac174dcf311f35b885527ff55e5
parent7d423a3a0ff5e0c70bac83585b593b910f627d15
Patch for GetCommandForPid() in osdep_darwin.c

the function mentioned above caused segfaults on MacOS. The attached patch
seems to solve that.

Details: The functions provides an array of string pointers (the argument
vector) pointing to a buffer allocated and referred to by a static local
variable `args`. This buffer was used on each subsequent call. For one
thing this would overwrite old values and for another this caused segfaults.

My new implementation allocates a buffer for the argument vector plus the
actual string data on each call. The caller will wfree() the buffer, but
until then has available an independent copy of the strings.
src/osdep_darwin.c