Просмотр исходного кода

Handle RATP station name if it can't allocate memory

DocSystem 1 год назад
Родитель
Сommit
298c5f793c
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      api/calypso/transit/navigo.c

+ 4 - 1
api/calypso/transit/navigo.c

@@ -252,7 +252,10 @@ char* get_navigo_station(
         if(station_group_id < 32 && station_id < 16) {
             const char* station_name = NAVIGO_RATP_LOCATION_LIST[station_group_id][station_id];
             if(station_name) {
-                return strdup(station_name);
+                char* station;
+                if((station = strdup(station_name)) != NULL) {
+                    return station;
+                }
             }
         }
         // cast station_group_id-station_id to a string