From 85213795d162ff03e48523afb854d6d6d17f27d4 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sat, 25 Aug 2018 09:27:41 +0200 Subject: [PATCH] GetDirectoryPath: return NULL, don't crash when no slash Noted in #634. --- src/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core.c b/src/core.c index 81ca2f58e..ce5104062 100644 --- a/src/core.c +++ b/src/core.c @@ -1374,6 +1374,9 @@ const char *GetDirectoryPath(const char *fileName) memset(filePath, 0, 256); lastSlash = strprbrk(fileName, "\\/"); + if (!lastSlash) + return NULL; + strncpy(filePath, fileName, strlen(fileName) - (strlen(lastSlash) - 1)); filePath[strlen(fileName) - strlen(lastSlash)] = '\0';