]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Storage API: add safety check for cases when there is no storage used.
authorVictor Julien <victor@inliniac.net>
Tue, 9 Apr 2013 09:11:35 +0000 (11:11 +0200)
committerVictor Julien <victor@inliniac.net>
Sun, 28 Jul 2013 21:41:11 +0000 (23:41 +0200)
src/flow-storage.c
src/host-storage.c

index 5685e717bdd2da843679544d85e97c2f1c71c40b..d8deca27ced89a64ff5755eff6a71914296c5a71 100644 (file)
@@ -52,7 +52,8 @@ void FlowFreeStorageById(Flow *f, int id) {
 }
 
 void FlowFreeStorage(Flow *f) {
-    StorageFreeAll((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW);
+    if (FlowStorageSize() > 0)
+        StorageFreeAll((Storage *)((void *)f + sizeof(Flow)), STORAGE_FLOW);
 }
 
 int FlowStorageRegister(const char *name, const unsigned int size, void *(*Init)(unsigned int), void (*Free)(void *)) {
index 3b391adfb5ec911595073ecf71503edbbcbd387b..b17606ae518e76e0b39726f520095d65a4ddb6bf 100644 (file)
@@ -48,7 +48,8 @@ void HostFreeStorageById(Host *h, int id) {
 }
 
 void HostFreeStorage(Host *h) {
-    StorageFreeAll((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST);
+    if (HostStorageSize() > 0)
+        StorageFreeAll((Storage *)((void *)h + sizeof(Host)), STORAGE_HOST);
 }
 
 int HostStorageRegister(const char *name, const unsigned int size, void *(*Init)(unsigned int), void (*Free)(void *)) {