teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.6.0-rpmds-null.patch

Panu Matilainen d05ecc
commit 3448b552964a526641d2e85b4ed27ebe3465f100
Panu Matilainen d05ecc
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen d05ecc
Date:   Thu Feb 26 10:49:38 2009 +0200
Panu Matilainen d05ecc
Panu Matilainen d05ecc
    Handle empty argv passed to rpmdsDupArgv()
Panu Matilainen d05ecc
    - same as 94552b96256c3620b4be407c501d0d926c081963, apt-rpm expects to
Panu Matilainen d05ecc
      pass empty version as NULL to rpmdsSingle()
Panu Matilainen d05ecc
Panu Matilainen d05ecc
diff --git a/lib/rpmds.c b/lib/rpmds.c
Panu Matilainen d05ecc
index 02b539c..bc829f4 100644
Panu Matilainen d05ecc
--- a/lib/rpmds.c
Panu Matilainen d05ecc
+++ b/lib/rpmds.c
Panu Matilainen d05ecc
@@ -508,15 +508,14 @@ const char ** rpmdsDupArgv(const char ** argv, int argc)
Panu Matilainen d05ecc
 
Panu Matilainen d05ecc
     if (argv == NULL)
Panu Matilainen d05ecc
 	return NULL;
Panu Matilainen d05ecc
-    for (ac = 0; ac < argc; ac++) {
Panu Matilainen d05ecc
-assert(argv[ac] != NULL);
Panu Matilainen d05ecc
+    for (ac = 0; ac < argc && argv[ac]; ac++) {
Panu Matilainen d05ecc
 	nb += strlen(argv[ac]) + 1;
Panu Matilainen d05ecc
     }
Panu Matilainen d05ecc
     nb += (ac + 1) * sizeof(*av);
Panu Matilainen d05ecc
 
Panu Matilainen d05ecc
     av = xmalloc(nb);
Panu Matilainen d05ecc
     t = (char *) (av + ac + 1);
Panu Matilainen d05ecc
-    for (ac = 0; ac < argc; ac++) {
Panu Matilainen d05ecc
+    for (ac = 0; ac < argc && argv[ac]; ac++) {
Panu Matilainen d05ecc
 	av[ac] = t;
Panu Matilainen d05ecc
 	t = stpcpy(t, argv[ac]) + 1;
Panu Matilainen d05ecc
     }