From 524c594a736604fbc32b48d28677f2346d3ef6fc Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 14 Dec 2020 20:58:13 +0000 Subject: [PATCH] SDL: Use sizeof to determine buffer sizes I think the use of 2048 was a typo, so this prevents one like that from happening again. --- src/sdl/SDL.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index 3e6d0f33..e0de8a83 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -366,7 +366,7 @@ FILE* sdlFindFile(const char* name) fprintf(stdout, "Searching for file %s\n", name); - if (GETCWD(buffer, 2048)) { + if (GETCWD(buffer, sizeof(buffer))) { fprintf(stdout, "Searching current directory: %s\n", buffer); } @@ -398,8 +398,8 @@ FILE* sdlFindFile(const char* name) if (path != NULL) { fprintf(stdout, "Searching PATH\n"); - strncpy(buffer, path, 4096); - buffer[4095] = 0; + strncpy(buffer, path, sizeof(buffer)); + buffer[sizeof(buffer) - 1] = 0; char* tok = strtok(buffer, PATH_SEP); while (tok) {