Explorar o código

Handle RATP station name if it can't allocate memory

DocSystem hai 1 ano
pai
achega
298c5f793c
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  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) {
         if(station_group_id < 32 && station_id < 16) {
             const char* station_name = NAVIGO_RATP_LOCATION_LIST[station_group_id][station_id];
             const char* station_name = NAVIGO_RATP_LOCATION_LIST[station_group_id][station_id];
             if(station_name) {
             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
         // cast station_group_id-station_id to a string