fix: memory leak and crash when id is NULL in iq_id_handler_add (upstream 0218ba26)

This commit is contained in:
2026-03-31 18:56:02 +03:00
parent 0b7ec1c5b6
commit a9ee765c49

View File

@@ -358,6 +358,13 @@ _iq_id_handler_free(ProfIqHandler* handler)
void
iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
{
if (id == NULL) {
if (free_func) {
free_func(userdata);
}
return;
}
ProfIqHandler* handler = malloc(sizeof(ProfIqHandler));
if (handler) {
handler->func = func;