diff --git a/du6/a_station.c b/du6/a_station.c index a66ad89..5e6dda3 100644 --- a/du6/a_station.c +++ b/du6/a_station.c @@ -103,13 +103,20 @@ int get_target_capacity(struct station* station,const char* target) int count_targets(struct station* station) { + if (station == NULL) + { + return 0; + } + int count = 0; for (int i = 0; i < station->track_count; i++) { struct car* currentTracks = station->tracks[i]; - while (currentTracks->next->value != NULL && currentTracks->next != NULL) + // while (currentTracks->next->value != NULL && currentTracks->next != NULL) + while (currentTracks != NULL) { count += 1; + currentTracks = currentTracks->next; } } return count;