check before dereference.
authorAlan T. DeKok <aland@freeradius.org>
Fri, 26 May 2017 14:54:14 +0000 (10:54 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 26 May 2017 14:54:14 +0000 (10:54 -0400)
Found by PVS-Studio

src/modules/rlm_passwd/rlm_passwd.c

index e8cd8af..b6b9ba0 100644 (file)
@@ -134,10 +134,11 @@ static void release_hash_table(struct hashtable * ht){
        int i;
 
        if (!ht) return;
-       for (i = 0; i < ht->tablesize; i++)
-               if (ht->table[i])
-                       destroy_password(ht->table[i]);
        if (ht->table) {
+               for (i = 0; i < ht->tablesize; i++) {
+                       if (ht->table[i])
+                               destroy_password(ht->table[i]);
+               }
                free(ht->table);
                ht->table = NULL;
        }