From f5d6f9b6d42830d659b73989819b15bd8bc62ab9 Mon Sep 17 00:00:00 2001 From: magnum Date: Wed, 27 Jan 2016 13:30:38 +0100 Subject: [PATCH] Do not create a kernel cache file if build failed. Also disregard any existing cache files with size of zero. Should close #164. --- src/oclHashcat.c | 2 +- src/shared.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/oclHashcat.c b/src/oclHashcat.c index 91d74e2a1..87b5b6b0a 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -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; } diff --git a/src/shared.c b/src/shared.c index 111f5476a..08f2389b7 100644 --- a/src/shared.c +++ b/src/shared.c @@ -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); + } } /**