From ed2d50a9fe80d3d2be920826391a07706d3b1175 Mon Sep 17 00:00:00 2001 From: opencode Date: Sun, 29 Nov 2026 18:41:57 +0000 Subject: [PATCH] fix: _psCreateFolder creates the dir without relying on realpath side effects --- src/skel/glfw/glfw.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index f1f97ee3..ebcc2fba 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -120,14 +120,11 @@ void _psCreateFolder(const char *path) CloseHandle(hfle); #else struct stat info; - char fullpath[PATH_MAX]; - realpath(path, fullpath); - - if (lstat(fullpath, &info) != 0) { - if (errno == ENOENT || (errno != EACCES && !S_ISDIR(info.st_mode))) { - mkdir(fullpath, 0755); - } - } + // realpath() can't resolve the folder before it exists and leaves its output + // buffer unspecified when it returns NULL, so create the folder from the path + // as given instead of trusting the resolved buffer. + if (lstat(path, &info) != 0 && errno == ENOENT) + mkdir(path, 0755); #endif }