Skip to content

Commit 495a12f

Browse files
regitvictorjulien
authored andcommitted
datasets: remove useless NULL check
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.
1 parent e947c40 commit 495a12f

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/datasets-context-json.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,10 @@ Dataset *DatajsonGet(const char *name, enum DatasetTypes type, const char *load,
716716
DatasetUnlock();
717717
return set;
718718
out_err:
719-
if (set) {
720-
if (set->hash) {
721-
THashShutdown(set->hash);
722-
}
723-
SCFree(set);
719+
if (set->hash) {
720+
THashShutdown(set->hash);
724721
}
722+
SCFree(set);
725723
DatasetUnlock();
726724
return NULL;
727725
}

src/datasets.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,10 @@ Dataset *DatasetGet(const char *name, enum DatasetTypes type, const char *save,
520520
DatasetUnlock();
521521
return set;
522522
out_err:
523-
if (set) {
524-
if (set->hash) {
525-
THashShutdown(set->hash);
526-
}
527-
SCFree(set);
523+
if (set->hash) {
524+
THashShutdown(set->hash);
528525
}
526+
SCFree(set);
529527
DatasetUnlock();
530528
return NULL;
531529
}

0 commit comments

Comments
 (0)