]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/mifarehost.c
Merge branch 'master' of https://github.com/iceman1001/proxmark3
[proxmark3-svn] / client / mifarehost.c
index b41c368702e6cbb4c94e82ee519ff9f2b5e7c8f5..b7cd3b590cea356100bfdc8f7be793f91e388f00 100644 (file)
@@ -412,14 +412,20 @@ int loadTraceCard(uint8_t *tuid, uint8_t uidlen) {
                memset(buf, 0, sizeof(buf));\r
                if (fgets(buf, sizeof(buf), f) == NULL) {\r
                        PrintAndLog("No trace file found or reading error.");\r
-                       fclose(f);\r
+                       if (f) {\r
+                               fclose(f);\r
+                               f = NULL;\r
+                       }\r
                        return 2;\r
                }\r
 \r
                if (strlen(buf) < 32){\r
                        if (feof(f)) break;\r
                        PrintAndLog("File content error. Block data must include 32 HEX symbols");\r
-                       fclose(f);\r
+                       if (f) {\r
+                               fclose(f);\r
+                               f = NULL;\r
+                       }\r
                        return 2;\r
                }\r
                for (i = 0; i < 32; i += 2)\r
@@ -429,7 +435,10 @@ int loadTraceCard(uint8_t *tuid, uint8_t uidlen) {
 \r
                blockNum++;\r
        }\r
-       fclose(f);\r
+       if (f) {\r
+               fclose(f);\r
+               f = NULL;\r
+       }\r
        return 0;\r
 }\r
 \r
@@ -447,7 +456,10 @@ int saveTraceCard(void) {
                fprintf(f,"\n");\r
        }\r
        fflush(f);\r
-       fclose(f);\r
+       if (f) {\r
+               fclose(f);\r
+               f = NULL;\r
+       }\r
        return 0;\r
 }\r
 \r
Impressum, Datenschutz