From: Jim Meyering Date: Thu, 13 Oct 2016 21:59:10 +0000 (-0700) Subject: getprogname: IBM z/OS: avoid NULL-dereference X-Git-Tag: v1.0~6606 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=7dad5f25591de682c452c3fc39ffe2fa11e21491;p=gnulib.git getprogname: IBM z/OS: avoid NULL-dereference * lib/getprogname.c (getprogname) [__MVS__]: Don't dereference NULL upon strdup failure. --- diff --git a/ChangeLog b/ChangeLog index f94feb1982..5b5f81dc78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-10-13 Jim Meyering + + getprogname: IBM z/OS: avoid NULL-dereference + * lib/getprogname.c (getprogname) [__MVS__]: Don't dereference NULL + upon strdup failure. + 2016-10-12 Jim Meyering test-stdint: use _GL_VERIFY rather than "verify" for some tests diff --git a/lib/getprogname.c b/lib/getprogname.c index a19612ab37..0e8d963c0f 100644 --- a/lib/getprogname.c +++ b/lib/getprogname.c @@ -104,7 +104,9 @@ getprogname (void) { if (token > 0 && buf.ps_pid == pid) { - p = strdup (last_component (buf.ps_pathptr)); + char *s = strdup (last_component (buf.ps_pathptr)); + if (s) + p = s; break; } }