]> git.cworth.org Git - tar/blobdiff - lib/getopt.c
Avoid undefined behavior of passing NULL to strcmp
[tar] / lib / getopt.c
index f1e6d1f7c702a4015baa324e85fe4fa41cb803e6..f1c0e1f24567aecde91a9953f571b1f8f279a5ec 100644 (file)
@@ -413,7 +413,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
         then exchange with previous non-options as if it were an option,
         then skip everything else like a non-option.  */
 
-      if (d->optind != argc && !strcmp (argv[d->optind], "--"))
+      if (d->optind != argc && argv[d->optind] && !strcmp (argv[d->optind], "--"))
        {
          d->optind++;