From 879f40a0aeffed412106edb4cb7f26a92a72ddd0 Mon Sep 17 00:00:00 2001 From: Stu Tomlinson Date: Wed, 2 Mar 2022 11:25:05 +0000 Subject: [PATCH] Minor compile warning fix src/handler.c: In function 'handler_system_delete_all': src/handler.c:706:25: warning: 'key2' may be used uninitialized in this function [-Wmaybe-uninitialized] hash_add(conn->id_handlers, key2, head); --- src/handler.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/handler.c b/src/handler.c index e3bfecb..43a2727 100644 --- a/src/handler.c +++ b/src/handler.c @@ -694,19 +694,18 @@ void handler_system_delete_all(xmpp_conn_t *conn) } else item = item->next; } - if (head != head_old) - key2 = key; /* Hash table implementation is not perfect, so we need to find next key before dropping current one. Otherwise, we will get access to freed memory. */ - key = hash_iter_next(iter); + key2 = hash_iter_next(iter); if (head != head_old) { /* hash_add() replaces value if the key exists */ if (head != NULL) - hash_add(conn->id_handlers, key2, head); + hash_add(conn->id_handlers, key, head); else - hash_drop(conn->id_handlers, key2); + hash_drop(conn->id_handlers, key); } + key = key2; } if (iter) hash_iter_release(iter);