diff --git a/omweather-hko-gov-hk-stations-db/src/meego-main.cpp b/omweather-hko-gov-hk-stations-db/src/meego-main.cpp index a4c1afb7e..9d9508fe7 100644 --- a/omweather-hko-gov-hk-stations-db/src/meego-main.cpp +++ b/omweather-hko-gov-hk-stations-db/src/meego-main.cpp @@ -122,8 +122,7 @@ parse_forecast_weather(const char *detail_path_data, const char *result_file){ t_end = t_start + 3600*24 - 1; fprintf(file_out," end=\"%li\">\n", t_end); number_of_day ++; - fgets(buffer2, sizeof(buffer2), file_in2); - if (comma = strstr(buffer2, "no. ")){ + if ((fgets(buffer2, sizeof(buffer2), file_in2) != NULL) && (comma = strstr(buffer2, "no. "))){ comma = comma + 3; icon = atoi (comma); snprintf(temp_buffer, sizeof(temp_buffer) - 1, "%i", icon); diff --git a/omweather-hko-gov-hk-stations-db/test.sh b/omweather-hko-gov-hk-stations-db/test.sh index 130282980..4987a0fe2 100755 --- a/omweather-hko-gov-hk-stations-db/test.sh +++ b/omweather-hko-gov-hk-stations-db/test.sh @@ -1,2 +1,5 @@ #!/bin/bash - ./hkogovhk ./examples/nday.htm ./examples/out.xml ./examples/englishwx2.htm +# ./hkogovhk ./examples/nday.htm ./examples/out.xml ./examples/englishwx2.htm + +valgrind --tool=memcheck --log-file=1.log -v --track-origins=yes --leak-check=full --show-reachable=yes ./hkogovhk ./examples/nday.htm ./examples/out.xml ./examples/englishwx2.htm +