(svn r26061) -Fix: negative result of ftell wasn't handled correctly in some cases

This commit is contained in:
rubidium
2013-11-23 13:17:45 +00:00
parent 29ef70c246
commit 78a316d349
3 changed files with 8 additions and 5 deletions

View File

@@ -360,10 +360,10 @@ static bool CalcGRFMD5Sum(GRFConfig *config, Subdirectory subdir)
f = FioFOpenFile(config->filename, "rb", subdir, &size);
if (f == NULL) return false;
size_t start = ftell(f);
long start = ftell(f);
size = min(size, GRFGetSizeOfDataSection(f));
if (fseek(f, start, SEEK_SET) < 0) {
if (start < 0 || fseek(f, start, SEEK_SET) < 0) {
FioFCloseFile(f);
return false;
}