summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAhmad Fatoum <[email protected]>2018-08-25 09:27:41 +0200
committerAhmad Fatoum <[email protected]>2018-08-25 09:27:41 +0200
commit85213795d162ff03e48523afb854d6d6d17f27d4 (patch)
tree13bf50e0f9f7119a0346a613ffd9d8121766af5e
parent5dda105a79c5d258a3c1ae48bb35ce817540b632 (diff)
downloadraylib-85213795d162ff03e48523afb854d6d6d17f27d4.tar.gz
raylib-85213795d162ff03e48523afb854d6d6d17f27d4.zip
GetDirectoryPath: return NULL, don't crash when no slash
Noted in #634.
-rw-r--r--src/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index 81ca2f58..ce510406 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';