aboutsummaryrefslogtreecommitdiffstats
path: root/icepll
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2019-05-26 16:17:32 +0200
committerMichael Buesch <m@bues.ch>2019-05-26 16:18:30 +0200
commitf848eb8b1216663d6c6b72a53f9d2a483cefb1ad (patch)
tree34c0198778e798323fcad04b85bc9305d92f2550 /icepll
parent2cee28fd470d4e79ea7f3f279c4a686846302a04 (diff)
downloadicestorm-f848eb8b1216663d6c6b72a53f9d2a483cefb1ad.tar.gz
icestorm-f848eb8b1216663d6c6b72a53f9d2a483cefb1ad.tar.bz2
icestorm-f848eb8b1216663d6c6b72a53f9d2a483cefb1ad.zip
icepll: Avoid segmentation fault, if opening of output file fails
Diffstat (limited to 'icepll')
-rw-r--r--icepll/icepll.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/icepll/icepll.cc b/icepll/icepll.cc
index 689b362..192eee6 100644
--- a/icepll/icepll.cc
+++ b/icepll/icepll.cc
@@ -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)
{