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 *parent;
struct GraphNode **firstChild; struct GraphNode **firstChild;
if (graphNode == NULL) { return NULL; }
parent = graphNode->parent; parent = graphNode->parent;
firstChild = &parent->children; firstChild = &parent->children;
// Remove link with siblings // Remove link with siblings
if (graphNode->prev != NULL && graphNode->next != NULL) {
graphNode->prev->next = graphNode->next; graphNode->prev->next = graphNode->next;
graphNode->next->prev = graphNode->prev; graphNode->next->prev = graphNode->prev;
}
// If this node was the first child, a new first child must be chosen // If this node was the first child, a new first child must be chosen
if (*firstChild == graphNode) { if (*firstChild == graphNode) {