[Mndiff-dev] [mndiff]: r34 - trunk/mnzip/mnzip.c

michael subversion at mplayerhq.hu
Mon Jun 18 10:56:30 CEST 2007


Author: michael
Date: Mon Jun 18 10:56:30 2007
New Revision: 34

Log:
fopen_error.diff
This fixes a segfault when the input file is inaccessible.
patch by (Corey Hickey bugfood-ml ot fatooh dat org)


Modified:
   trunk/mnzip/mnzip.c

Modified: trunk/mnzip/mnzip.c
==============================================================================
--- trunk/mnzip/mnzip.c	(original)
+++ trunk/mnzip/mnzip.c	Mon Jun 18 10:56:30 2007
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <assert.h>
 #include <math.h>
+#include <errno.h>
 
 
 #undef NDEBUG
@@ -851,7 +852,7 @@ static void help(void){
 }
 
 int main(int argc, char **argv){
-    FILE *fi= fopen(argv[2], "rb");
+    FILE *fi;
     uint8_t *out, *in;
     int comp= !strcmp(argv[0], "mnzib");
     int low_mem= 0;
@@ -873,6 +874,11 @@ int main(int argc, char **argv){
         }
     }
 
+    if (! (fi = fopen(argv[2], "rb"))) {
+        perror("Error opening input file");
+        exit(1);
+    }
+
     init_prob(prob);
 
     if(comp){



More information about the Mndiff-dev mailing list