fixed possible get_node issue

This commit is contained in:
Václav Šmejkal 2023-02-02 15:20:45 +01:00
parent 568ac4e43e
commit 17cc602629
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -83,6 +83,8 @@ node_t *get_node(void *pointer)
buffer = buffer -> next;
}
if (pointer != buffer -> pointer) buffer = NULL; //PREVENT FROM RETURNING INVALID NODE
return buffer;
}
@ -128,10 +130,10 @@ void why2_free(void *pointer)
//VARIABLES
node_t *node = get_node(pointer);
if (pointer == node)
if (pointer != NULL)
{
remove_node(node); //REMOVE FROM LIST IF FOUND
} //TODO: ELSE happens really often
}
free(pointer);
}