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);
This commit is contained in:
Stu Tomlinson
2022-03-02 11:25:05 +00:00
parent 0365f03342
commit 879f40a0ae

View File

@@ -694,19 +694,18 @@ void handler_system_delete_all(xmpp_conn_t *conn)
} else } else
item = item->next; item = item->next;
} }
if (head != head_old)
key2 = key;
/* Hash table implementation is not perfect, so we need to find next /* Hash table implementation is not perfect, so we need to find next
key before dropping current one. Otherwise, we will get access to key before dropping current one. Otherwise, we will get access to
freed memory. */ freed memory. */
key = hash_iter_next(iter); key2 = hash_iter_next(iter);
if (head != head_old) { if (head != head_old) {
/* hash_add() replaces value if the key exists */ /* hash_add() replaces value if the key exists */
if (head != NULL) if (head != NULL)
hash_add(conn->id_handlers, key2, head); hash_add(conn->id_handlers, key, head);
else else
hash_drop(conn->id_handlers, key2); hash_drop(conn->id_handlers, key);
} }
key = key2;
} }
if (iter) if (iter)
hash_iter_release(iter); hash_iter_release(iter);