From bd7c795077a30a2b893544e8614a3440be7b22f3 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 22 Dec 2016 21:05:48 -0600 Subject: [PATCH] Fix build issue from previous commit and fix additional compiler warning --- src/ox/fs/oxfstool.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ox/fs/oxfstool.cpp b/src/ox/fs/oxfstool.cpp index 5c088a512..ab6f7ba3a 100644 --- a/src/ox/fs/oxfstool.cpp +++ b/src/ox/fs/oxfstool.cpp @@ -35,10 +35,10 @@ char *loadFileBuff(const char *path, ::size_t *sizeOut = nullptr) { const auto size = ftell(file); rewind(file); auto buff = (char*) malloc(size); - fread(buff, size, 1, file); + auto itemsRead = fread(buff, size, 1, file); fclose(file); if (sizeOut) { - *sizeOut = size; + *sizeOut = itemsRead ? size : 0; } return buff; } else { @@ -212,6 +212,7 @@ int write(int argc, char **args) { err = 1; } } + free(srcBuff); } else { err = 1; fprintf(stderr, "Could not load source file.\n"); @@ -219,7 +220,6 @@ int write(int argc, char **args) { } free(fsBuff); - free(srcBuff); } else { fprintf(stderr, "Could not open file system\n"); }