From 0977dd10171d9eb70715143f2c0e716beea488c1 Mon Sep 17 00:00:00 2001 From: Remco <remco@dutchcoders.io> Date: Tue, 24 May 2016 18:32:51 +0200 Subject: [PATCH] fixed comments --- kstool/kstool.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kstool/kstool.cpp b/kstool/kstool.cpp index 06b441d..d861c69 100644 --- a/kstool/kstool.cpp +++ b/kstool/kstool.cpp @@ -87,11 +87,16 @@ int main(int argc, char **argv) fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); - unsigned int index = 0; + size_t index = 0; char buf[1024]; while( fgets(buf, sizeof(buf), stdin) ) { input = (char*)realloc(assembly, index + strlen(buf)); + if (!input) { + printf("Failed to allocate memory."); + return 1; + } + memcpy(&input[index], buf, strlen(buf)); index += strlen(buf); } @@ -253,8 +258,7 @@ int main(int argc, char **argv) // close Keystone instance when done ks_close(ks); - if (input) - free(input); + free(input); return 0; } -- GitLab