Fixed crash in geo_remove_child()

This commit is contained in:
MysterD 2022-03-25 22:19:29 -07:00
parent b25bb84b48
commit 35d6fc0262
1 changed files with 6 additions and 2 deletions

View File

@ -578,12 +578,16 @@ struct GraphNode *geo_remove_child(struct GraphNode *graphNode) {
struct GraphNode *parent;
struct GraphNode **firstChild;
if (graphNode == NULL) { return NULL; }
parent = graphNode->parent;
firstChild = &parent->children;
// Remove link with siblings
graphNode->prev->next = graphNode->next;
graphNode->next->prev = graphNode->prev;
if (graphNode->prev != NULL && graphNode->next != NULL) {
graphNode->prev->next = graphNode->next;
graphNode->next->prev = graphNode->prev;
}
// If this node was the first child, a new first child must be chosen
if (*firstChild == graphNode) {