Fix a few stack problems

This commit is contained in:
Edgaru089 2024-05-05 13:36:53 +08:00
parent 4873eb898a
commit 102a2cd707
3 changed files with 6 additions and 3 deletions

View File

@ -44,6 +44,8 @@
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
<EnableFuzzer>true</EnableFuzzer>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>

View File

@ -19,7 +19,7 @@ void lboard_LoadFromFile(System_Leaderboards *sys, const char *filename) {
char linebuf[512]; char linebuf[512];
memset(linebuf, 0, sizeof(linebuf)); memset(linebuf, 0, sizeof(linebuf));
while (!feof(f) && fgets(linebuf, sizeof(linebuf), f)) { 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'; linebuf[strlen(linebuf) - 1] = '\0';
// Skip empty lines // Skip empty lines

View File

@ -119,8 +119,9 @@ void render_LoadBundle(const char *filename) {
} }
char linebuf[512]; char linebuf[512];
while (!feof(f) && fgets(linebuf, sizeof(linebuf), f)) { memset(linebuf, 0, sizeof(linebuf));
while (linebuf[strlen(linebuf) - 1] == '\n') while (!feof(f) && fgets(linebuf, sizeof(linebuf) - 1, f)) {
while (linebuf[0] !='\0' && linebuf[strlen(linebuf) - 1] == '\n')
linebuf[strlen(linebuf) - 1] = '\0'; linebuf[strlen(linebuf) - 1] = '\0';
char *cmd = strtok(linebuf, " "); char *cmd = strtok(linebuf, " ");