mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-22 02:20:25 +01:00
Remove close/reopen logic for file handle and fix Ecc crash on empty
This commit is contained in:
parent
9f50d3ef84
commit
609d71437f
|
@ -239,7 +239,7 @@ enum ESStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Determine whether or not our target ES file is indeed valid input. */
|
/* Determine whether or not our target ES file is indeed valid input. */
|
||||||
ESStatus GetESStatus(char *filename)
|
ESStatus GetESStatus()
|
||||||
{
|
{
|
||||||
ESStatus result = ESStatus::Empty;
|
ESStatus result = ESStatus::Empty;
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ ESStatus GetESStatus(char *filename)
|
||||||
char* temporaryBuffer = (char*)malloc(length);
|
char* temporaryBuffer = (char*)malloc(length);
|
||||||
fseek(_fInput, 0, SEEK_SET);
|
fseek(_fInput, 0, SEEK_SET);
|
||||||
fread(temporaryBuffer, length, 1, _fInput);
|
fread(temporaryBuffer, length, 1, _fInput);
|
||||||
fclose(_fInput);
|
fseek(_fInput, 0, SEEK_SET);
|
||||||
|
|
||||||
// Loop through each line
|
// Loop through each line
|
||||||
char* currentSequence = strtok(temporaryBuffer, "\n");
|
char* currentSequence = strtok(temporaryBuffer, "\n");
|
||||||
|
@ -315,18 +315,11 @@ ESStatus GetESStatus(char *filename)
|
||||||
result = ESStatus::Good;
|
result = ESStatus::Good;
|
||||||
|
|
||||||
free(temporaryBuffer);
|
free(temporaryBuffer);
|
||||||
if (result == ESStatus::Good)
|
|
||||||
_fInput = FOpen(filename, "r");
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(currentSequence = strtok(NULL, "\n"));
|
while(currentSequence = strtok(NULL, "\n"));
|
||||||
|
|
||||||
free(temporaryBuffer);
|
|
||||||
if (result == ESStatus::Good)
|
|
||||||
_fInput = FOpen(filename, "r");
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +381,7 @@ int main(int argc, char *argv[])
|
||||||
_fInput = FOpen(argv[1], "r");
|
_fInput = FOpen(argv[1], "r");
|
||||||
|
|
||||||
// Make sure we're loading a valid ES file
|
// Make sure we're loading a valid ES file
|
||||||
ESStatus status = GetESStatus(argv[1]);
|
ESStatus status = GetESStatus();
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user