mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-07-01 08:23:33 +02:00
Duplicate setprogname argument
For some reason, accessing the argv vector directly may cause SIGSEV.
This commit is contained in:
parent
3462d1261f
commit
1d87476250
@ -19,9 +19,10 @@
|
|||||||
Rejected in glibc (http://sourceware.org/ml/libc-alpha/2006-03/msg00125.html)
|
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 *
|
char *
|
||||||
getprogname ()
|
getprogname ()
|
||||||
@ -32,5 +33,10 @@ getprogname ()
|
|||||||
void
|
void
|
||||||
setprogname (char *new)
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user