]> Savannah Git Hosting - gnulib.git/commitdiff
getprogname: IBM z/OS: avoid NULL-dereference
authorJim Meyering <meyering@fb.com>
Thu, 13 Oct 2016 21:59:10 +0000 (14:59 -0700)
committerJim Meyering <meyering@fb.com>
Thu, 13 Oct 2016 21:59:10 +0000 (14:59 -0700)
* lib/getprogname.c (getprogname) [__MVS__]: Don't dereference NULL
upon strdup failure.

ChangeLog
lib/getprogname.c

index f94feb1982406149750f837911c27351c37e8eb0..5b5f81dc781eb96bd4cb6148294509fe1933a741 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-10-13  Jim Meyering  <meyering@fb.com>
+
+       getprogname: IBM z/OS: avoid NULL-dereference
+       * lib/getprogname.c (getprogname) [__MVS__]: Don't dereference NULL
+       upon strdup failure.
+
 2016-10-12  Jim Meyering  <meyering@fb.com>
 
        test-stdint: use _GL_VERIFY rather than "verify" for some tests
index a19612ab37afe0675439b33377acdc67221b2020..0e8d963c0f3fd2ce7e204e4bd2f408208fb68d8c 100644 (file)
@@ -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;
                 }
             }