From: Victor Julien Date: Tue, 18 Mar 2025 21:26:53 +0000 (+0100) Subject: datasets: work around scan-build warning X-Git-Tag: suricata-7.0.10~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6fd3e69bc109abe9042ceb716a2f9e67d293b19;p=thirdparty%2Fsuricata.git datasets: work around scan-build warning datasets.c:493:27: warning: Dereference of null pointer [core.NullDereference] 493 | DEBUG_VALIDATE_BUG_ON(set->hash->config.hash_size != hashsize); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ./util-validate.h:95:44: note: expanded from macro 'DEBUG_VALIDATE_BUG_ON' 95 | #define DEBUG_VALIDATE_BUG_ON(exp) BUG_ON((exp)) | ^~~ ./suricata-common.h:307:36: note: expanded from macro 'BUG_ON' 307 | #define BUG_ON(x) assert(!(x)) | ^ /usr/include/assert.h:109:7: note: expanded from macro 'assert' 109 | ((expr) \ | ^~~~ 1 warning generated. (cherry picked from commit c6fdf99cec1ba7067b20e68ea4e812cb4c043881) --- diff --git a/src/datasets.c b/src/datasets.c index 412413ab4a..db9da76680 100644 --- a/src/datasets.c +++ b/src/datasets.c @@ -786,8 +786,11 @@ Dataset *DatasetGet(const char *name, enum DatasetTypes type, const char *save, goto out_err; break; } + if (set->hash == NULL) { + goto out_err; + } - if (set->hash && SC_ATOMIC_GET(set->hash->memcap_reached)) { + if (SC_ATOMIC_GET(set->hash->memcap_reached)) { SCLogError("dataset too large for set memcap"); goto out_err; }