diff --git a/winpr/libwinpr/timezone/timezone.c b/winpr/libwinpr/timezone/timezone.c index c29c1bb00..f49e0b6f0 100644 --- a/winpr/libwinpr/timezone/timezone.c +++ b/winpr/libwinpr/timezone/timezone.c @@ -64,7 +64,8 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp) do { rc = fread(tzid + read, 1, length - read - 1, fp); - read += rc; + if (rc > 0) + read += rc; if (read < (length - 1)) break; @@ -87,8 +88,11 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp) } tzid[read] = '\0'; - if (tzid[read - 1] == '\n') - tzid[read - 1] = '\0'; + if (read > 0) + { + if (tzid[read - 1] == '\n') + tzid[read - 1] = '\0'; + } return tzid; }