summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorErik Troan <ewt@src.gnome.org>1997-01-30 20:04:11 +0000
committerErik Troan <ewt@src.gnome.org>1997-01-30 20:04:11 +0000
commitd8741588589769b5773c544580171f62a5d8e6c5 (patch)
treecb16f915ac627f8ace99fa3436ea8ade3a568acf /support
parent35feb966b7490c06b27414cc619febe5b30e94e7 (diff)
downloadgnome-common-d8741588589769b5773c544580171f62a5d8e6c5.tar.gz
NULL terminate result of poptGetArgs()2-3-52-3-4
svn path=/trunk/; revision=6
Diffstat (limited to 'support')
-rw-r--r--support/popt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/support/popt.c b/support/popt.c
index 930cc5e..281cd35 100644
--- a/support/popt.c
+++ b/support/popt.c
@@ -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);
}