]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Add some (unnecessary) checks to unconfuse clang
authorRuss Allbery <eagle@eyrie.org>
Mon, 16 Dec 2013 21:14:58 +0000 (13:14 -0800)
committerRuss Allbery <eagle@eyrie.org>
Mon, 16 Dec 2013 21:14:58 +0000 (13:14 -0800)
When parsing character class configuration, check for NULL explicitly
so that clang knows that the NULL case is handled properly.

plugin/config.c

index 33fc07aacde94aeef6530092d8a92bdc22ca4ca2..6aaa21a40b31062cc2ce1d918d53c8ebf52d4ed7 100644 (file)
@@ -165,6 +165,8 @@ parse_class(krb5_context ctx, const char *spec, struct class_rule **rule)
 
     /* Create the basic rule structure. */
     *rule = calloc(1, sizeof(struct class_rule));
+    if (*rule == NULL)
+        return strength_error_system(ctx, "cannot allocate memory");
 
     /*
      * If the rule starts with a digit, it starts with a range of affected
@@ -249,12 +251,12 @@ strength_config_classes(krb5_context ctx, const char *opt,
 
     /* Each word in the list will be a class rule. */
     code = parse_class(ctx, config->strings[0], &rules);
-    if (code != 0)
+    if (code != 0 || rules == NULL)
         goto fail;
     last = rules;
     for (i = 1; i < config->count; i++) {
         code = parse_class(ctx, config->strings[i], &last->next);
-        if (code != 0)
+        if (code != 0 || last->next == NULL)
             goto fail;
         last = last->next;
     }