diff --git a/du4/a_train.c b/du4/a_train.c index 1321d8f..241bbbd 100644 --- a/du4/a_train.c +++ b/du4/a_train.c @@ -68,10 +68,10 @@ struct car* clear_train(struct car* first, const char* target) { prev = temp; temp = temp->next; if(strcmp(temp->value, target) == 0){ - - prev->next = temp->next; + struct car* next = temp->next; + prev->next = next; free(temp); - temp = prev->next; + temp = next; }