From f3bc8d31ade109d113e456d3a9fd6f399a5814bb Mon Sep 17 00:00:00 2001 From: Anton Dolozin Date: Tue, 4 Nov 2025 22:44:01 +0100 Subject: [PATCH] Fixing the memory problems --- du5/a_station.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/du5/a_station.c b/du5/a_station.c index be8814c..44b8c1d 100644 --- a/du5/a_station.c +++ b/du5/a_station.c @@ -31,13 +31,13 @@ void add_target_capacity(struct station* station,const char* target, int capacit struct car* ptr = *station->tracks; int count = 0; int res = select_track(station, target); - while(count != res){ + while(count != res && ptr){ ptr = ptr->next; count++; } - if(!ptr){ + if(!ptr->next){ ptr = (struct car*)calloc(capacity, sizeof(struct car)); ptr->capacity = capacity; strcpy(ptr->value, target);