From 102a2cd707de2e7581e5e9cac4455cdb234ef483 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sun, 5 May 2024 13:36:53 +0800 Subject: [PATCH] Fix a few stack problems --- JacksEscape.vcxproj | 2 ++ leaderboards_file.c | 2 +- render_bundle_file.c | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/JacksEscape.vcxproj b/JacksEscape.vcxproj index 08f89e4..a269300 100644 --- a/JacksEscape.vcxproj +++ b/JacksEscape.vcxproj @@ -44,6 +44,8 @@ true v143 Unicode + true + true Application diff --git a/leaderboards_file.c b/leaderboards_file.c index 6faf3b6..d0d2300 100644 --- a/leaderboards_file.c +++ b/leaderboards_file.c @@ -19,7 +19,7 @@ void lboard_LoadFromFile(System_Leaderboards *sys, const char *filename) { char linebuf[512]; memset(linebuf, 0, sizeof(linebuf)); while (!feof(f) && fgets(linebuf, sizeof(linebuf), f)) { - while (linebuf[strlen(linebuf) - 1] == '\n') + while (linebuf[0] !='\0' && linebuf[strlen(linebuf) - 1] == '\n') linebuf[strlen(linebuf) - 1] = '\0'; // Skip empty lines diff --git a/render_bundle_file.c b/render_bundle_file.c index ad4a74b..de1463b 100644 --- a/render_bundle_file.c +++ b/render_bundle_file.c @@ -119,8 +119,9 @@ void render_LoadBundle(const char *filename) { } char linebuf[512]; - while (!feof(f) && fgets(linebuf, sizeof(linebuf), f)) { - while (linebuf[strlen(linebuf) - 1] == '\n') + memset(linebuf, 0, sizeof(linebuf)); + while (!feof(f) && fgets(linebuf, sizeof(linebuf) - 1, f)) { + while (linebuf[0] !='\0' && linebuf[strlen(linebuf) - 1] == '\n') linebuf[strlen(linebuf) - 1] = '\0'; char *cmd = strtok(linebuf, " ");