diff --git a/Startcode/stack.c b/Startcode/stack.c index 6477ba4..a09b8df 100644 --- a/Startcode/stack.c +++ b/Startcode/stack.c @@ -12,7 +12,9 @@ StackNode *push(StackNode *stack, void *data) { StackNode *newItem = (StackNode*)calloc(1, sizeof(StackNode)); if (newItem == NULL) return NULL; - stack->left = newItem; + if (stack != NULL) { + stack->left = newItem; + } newItem->right = stack; newItem->left = NULL; newItem->data = data;