mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 12:36:21 +00:00
fix: memory leak and crash when id is NULL in iq_id_handler_add (upstream 0218ba26)
This commit is contained in:
@@ -358,6 +358,13 @@ _iq_id_handler_free(ProfIqHandler* handler)
|
|||||||
void
|
void
|
||||||
iq_id_handler_add(const char* const id, ProfIqCallback func, ProfIqFreeCallback free_func, void* userdata)
|
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));
|
ProfIqHandler* handler = malloc(sizeof(ProfIqHandler));
|
||||||
if (handler) {
|
if (handler) {
|
||||||
handler->func = func;
|
handler->func = func;
|
||||||
|
|||||||
Reference in New Issue
Block a user