NULL terminate result of poptGetArgs()
authorewt <devnull@localhost>
Thu, 30 Jan 1997 20:04:11 +0000 (20:04 +0000)
committerewt <devnull@localhost>
Thu, 30 Jan 1997 20:04:11 +0000 (20:04 +0000)
CVS patchset: 1388
CVS date: 1997/01/30 20:04:11

popt/popt.c

index 930cc5e..281cd35 100644 (file)
@@ -40,7 +40,7 @@ poptContext poptGetContext(char * name ,int argc, char ** argv,
     con->os->currAlias = NULL;
     con->os->next = 1;                 /* skip argv[0] */
 
-    con->leftovers = malloc(sizeof(char *) * argc);
+    con->leftovers = malloc(sizeof(char *) * (argc + 1));
     con->numLeftovers = 0;
     con->nextLeftover = 0;
     con->restLeftover = 0;
@@ -214,6 +214,10 @@ char * poptPeekArg(poptContext con) {
 
 char ** poptGetArgs(poptContext con) {
     if (con->numLeftovers == con->nextLeftover) return NULL;
+
+    /* some apps like [like RPM ;-) ] need this NULL terminated */
+    con->leftovers[con->numLeftovers] = NULL;
+
     return (con->leftovers + con->nextLeftover);
 }