[02/10] batctl: Handle failure during hash_iterator allocation

Message ID 20171123140444.17119-3-sven.eckelmann@openmesh.com (mailing list archive)
State Accepted, archived
Commit aa316bf6d1b2cf0ab7189ed8620c17f5018d4d37
Delegated to: Simon Wunderlich
Headers
Series batctl: Fixes and minor cleanup |

Commit Message

Sven Eckelmann Nov. 23, 2017, 2:04 p.m. UTC
  The iterator functions should not try to start the iteration when the
iterator could not be allocated.

Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
---
 hash.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/hash.c b/hash.c
index f4a7af7..0e4d1e3 100644
--- a/hash.c
+++ b/hash.c
@@ -120,6 +120,9 @@  struct hash_it_t *hash_iterate(struct hashtable_t *hash,
 
 	if (iter_in == NULL) {
 		iter = debugMalloc(sizeof(struct hash_it_t), 301);
+		if (!iter)
+			return NULL;
+
 		iter->index =  -1;
 		iter->bucket = NULL;
 		iter->prev_bucket = NULL;