Merge pull request #219 from mbuesch/icepll-fix-fopen

icepll: Avoid segmentation fault, if opening of output file fails
This commit is contained in:
Clifford Wolf 2019-05-26 16:36:28 +02:00 committed by GitHub
commit 710470f9d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
@ -243,6 +244,12 @@ int main(int argc, char **argv)
// open file for writing
FILE *f;
f = fopen(filename, "w");
if (f == NULL)
{
fprintf(stderr, "Error: Failed to open output file '%s': %s\n",
filename, strerror(errno));
exit(1);
}
if (save_as_module)
{