From f848eb8b1216663d6c6b72a53f9d2a483cefb1ad Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 26 May 2019 16:17:32 +0200 Subject: icepll: Avoid segmentation fault, if opening of output file fails --- icepll/icepll.cc | 7 +++++++ 1 file changed, 7 insertions(+) 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 #include +#include #include #include #include @@ -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) { -- cgit v1.2.3