diff options
author | Robert Millan <rmh@aybabtu.com> | 2006-03-30 11:14:56 +0000 |
---|---|---|
committer | Guillem Jover <guillem@hadrons.org> | 2008-05-06 08:55:56 +0300 |
commit | 1d87476250217a87319df48a8f473415c0515106 (patch) | |
tree | 20f010e2d683385122be4299b1e01764d1af2c9a /src | |
parent | 3462d1261f2cd9ff26faaf4a0027c661b37af999 (diff) | |
download | libbsd-1d87476250217a87319df48a8f473415c0515106.tar.gz |
Duplicate setprogname argument
For some reason, accessing the argv vector directly may cause SIGSEV.
Diffstat (limited to 'src')
-rw-r--r-- | src/progname.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/progname.c b/src/progname.c index 7777658..e422b5e 100644 --- a/src/progname.c +++ b/src/progname.c @@ -19,9 +19,10 @@ Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html) */ -#include <bsd/stdlib.h> +#include <bsd/stdlib.h> /* progname, strdup */ +#include <string.h> /* free */ -static char *__progname = NULL; +char *__progname = NULL; char * getprogname () @@ -32,5 +33,10 @@ getprogname () void setprogname (char *new) { - __progname = new; + /* For some reason, accessing the argv vector directly may cause SIGSEV. Let's copy it to avoid trouble. */ + + if (__progname != NULL) + free (__progname); + + __progname = strdup (new); } |