if (!p) {\r
PrintAndLog("Cannot allocate memory for defaultKeys");\r
free(keyBlock);\r
- fclose(f);\r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
return 2;\r
}\r
keyBlock = p;\r
keycnt++;\r
memset(buf, 0, sizeof(buf));\r
} \r
- fclose(f);\r
- \r
+ if (f) {\r
+ fclose(f);\r
+ f = NULL;\r
+ }\r
if (keycnt == 0) {\r
PrintAndLog("No keys found in file");\r
free(keyBlock);\r