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

icepll: Avoid segmentation fault, if opening of output file fails
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 @@
 		// 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)
 		{