Do not create a kernel cache file if build failed. Also disregard any
authormagnum <john.magnum@hushmail.com>
Wed, 27 Jan 2016 12:30:38 +0000 (13:30 +0100)
committermagnum <john.magnum@hushmail.com>
Wed, 27 Jan 2016 17:39:45 +0000 (18:39 +0100)
existing cache files with size of zero. Should close #164.

src/oclHashcat.c
src/shared.c

index 91d74e2..87b5b6b 100644 (file)
@@ -13547,7 +13547,7 @@ int main (int argc, char **argv)
 
         struct stat cst;
 
-        if (stat (cached_file, &cst) == -1)
+        if ((stat (cached_file, &cst) == -1) || cst.st_size == 0)
         {
           cached = 0;
         }
index 111f547..08f2389 100644 (file)
@@ -8672,12 +8672,15 @@ void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengt
 
 void writeProgramBin (char *dst, u8 *binary, size_t binary_size)
 {
-  FILE *fp = fopen (dst, "wb");
+  if (binary_size > 0)
+  {
+    FILE *fp = fopen (dst, "wb");
 
-  fwrite (binary, sizeof (u8), binary_size, fp);
+    fwrite (binary, sizeof (u8), binary_size, fp);
 
-  fflush (fp);
-  fclose (fp);
+    fflush (fp);
+    fclose (fp);
+  }
 }
 
 /**