]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
datasets: remove useless NULL check 13483/head
authorEric Leblond <el@stamus-networks.com>
Mon, 16 Jun 2025 09:23:43 +0000 (11:23 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 18 Jun 2025 16:22:59 +0000 (18:22 +0200)
Coverity did detect that the cleaning code is only reached with
Dataset *set being initialized so the check is useless.

** CID 1649392:       Null pointer dereferences  (REVERSE_INULL)
/src/datasets-context-json.c: 719           in DatajsonGet()
>>>     Null-checking "set" suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.

** CID 1649391:       Null pointer dereferences  (REVERSE_INULL)
/src/datasets.c: 526           in DatasetGet()
>>>     Null-checking "set" suggests that it may be null, but it has
already been dereferenced on all paths leading to the check.

src/datasets-context-json.c
src/datasets.c

index 630069a0cba0dcfb3b5379f51c0559392d08b13d..3cc17d22f824e35ce7d7c724324e77c764ff1b10 100644 (file)
@@ -716,12 +716,10 @@ Dataset *DatajsonGet(const char *name, enum DatasetTypes type, const char *load,
     DatasetUnlock();
     return set;
 out_err:
-    if (set) {
-        if (set->hash) {
-            THashShutdown(set->hash);
-        }
-        SCFree(set);
+    if (set->hash) {
+        THashShutdown(set->hash);
     }
+    SCFree(set);
     DatasetUnlock();
     return NULL;
 }
index e0a46c7441944c04ba374c73d50ae438d71ed9f1..5a2daeed7cdeecc59c35ac3fa9662dd55b679211 100644 (file)
@@ -520,12 +520,10 @@ Dataset *DatasetGet(const char *name, enum DatasetTypes type, const char *save,
     DatasetUnlock();
     return set;
 out_err:
-    if (set) {
-        if (set->hash) {
-            THashShutdown(set->hash);
-        }
-        SCFree(set);
+    if (set->hash) {
+        THashShutdown(set->hash);
     }
+    SCFree(set);
     DatasetUnlock();
     return NULL;
 }