parser: Fail gracefully if a nonexistent file is passed on the command line
Before, if a nonexistent file was passed to LoadFileText(), it would return NULL, and the parser would happily dereference it.
This commit is contained in:
parent
07bbfe86b9
commit
0a679d794a
1 changed files with 6 additions and 0 deletions
|
@ -207,6 +207,12 @@ int main(int argc, char* argv[])
|
|||
int length = 0;
|
||||
char *buffer = LoadFileText(inFileName, &length);
|
||||
|
||||
if (buffer == NULL)
|
||||
{
|
||||
printf("Could not read input file: %s\n", inFileName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Preprocess buffer to get separate lines
|
||||
// NOTE: GetTextLines() also removes leading spaces/tabs
|
||||
int linesCount = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue