GetDirectoryPath: return NULL, don't crash when no slash

Noted in #634.
This commit is contained in:
Ahmad Fatoum 2018-08-25 09:27:41 +02:00
parent 5dda105a79
commit 85213795d1
No known key found for this signature in database
GPG key ID: C3EAC3DE9321D59B

View file

@ -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';