Bug 1208405 - Improved fix for a1d731d9694e, r=franziskus
authorMartin Thomson <martin.thomson@gmail.com>
Mon, 24 Oct 2016 21:31:48 +1100
changeset 12749 e6ad34c4144f35d47eb8986a4094d866cb1093c8
parent 12748 a1d731d9694ec8dbae284e5acfa4c6a94dff2800
child 12750 a1d2234bed689864b7b0007e5d422f2aef89f453
push id1691
push usermartin.thomson@gmail.com
push dateMon, 24 Oct 2016 10:32:00 +0000
reviewersfranziskus
bugs1208405
Bug 1208405 - Improved fix for a1d731d9694e, r=franziskus
cmd/lib/basicutil.c
--- a/cmd/lib/basicutil.c
+++ b/cmd/lib/basicutil.c
@@ -771,32 +771,35 @@ groupNameToNamedGroup(char *name)
     return ssl_grp_none;
 }
 
 SECStatus
 parseGroupList(const char *arg, SSLNamedGroup **enabledGroups,
                unsigned int *enabledGroupsCount)
 {
     SSLNamedGroup *groups;
-    char *str = PORT_Strdup(arg);
+    char *str;
+    char *p;
     unsigned int numValues = 0;
     unsigned int count = 0;
 
     /* Count the number of groups. */
-    char *p = strtok(str, ",");
+    str = PORT_Strdup(arg);
+    if (!str) {
+        return SECFailure;
+    }
+    p = strtok(str, ",");
     while (p) {
         ++numValues;
         p = strtok(NULL, ",");
     }
+    PORT_Free(str);
     groups = PORT_ZNewArray(SSLNamedGroup, numValues);
-    if (str) {
-        PORT_Free(str);
-    }
     if (!groups) {
-        return SECFailure;
+        goto done;
     }
 
     /* Get group names. */
     str = PORT_Strdup(arg);
     if (!str) {
         goto done;
     }
     p = strtok(str, ",");