initialize newly allocated data
authorNils Larsch <nils@openssl.org>
Fri, 1 Jul 2005 16:15:48 +0000 (16:15 +0000)
committerNils Larsch <nils@openssl.org>
Fri, 1 Jul 2005 16:15:48 +0000 (16:15 +0000)
PR: 1145

apps/apps.c

index 9ae3e16ed3bbfec66d22060bd3793e3ec55b5b6e..248c65adb395fcce69229b1bdbd9b7aeda90b6ea 100644 (file)
@@ -374,10 +374,17 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
                /* The start of something good :-) */
                if (num >= arg->count)
                        {
-                       arg->count+=20;
-                       arg->data=(char **)OPENSSL_realloc(arg->data,
-                               sizeof(char *)*arg->count);
-                       if (argc == 0) return(0);
+                       char **tmp_p;
+                       int tlen = arg->count + 20;
+                       tmp_p = (char **)OPENSSL_realloc(arg->data,
+                               sizeof(char *)*tlen);
+                       if (tmp_p == NULL)
+                               return 0;
+                       arg->data  = tmp_p;
+                       arg->count = tlen;
+                       /* initialize newly allocated data */
+                       for (i = num; i < arg->count; i++)
+                               arg->data[i] = NULL;
                        }
                arg->data[num++]=p;