summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2019-09-08 01:11:53 +0200
committerRay <[email protected]>2019-09-08 01:11:53 +0200
commitd93f8eadf838eaa688c5e139c76c7f02b1369f40 (patch)
tree0e26a7742195edf948774ecf11670e7169f83a4a /src/core.c
parent53b32f1c209051e87871c4cdd2e09828d8ac407e (diff)
downloadraylib-d93f8eadf838eaa688c5e139c76c7f02b1369f40.tar.gz
raylib-d93f8eadf838eaa688c5e139c76c7f02b1369f40.zip
REVIEW: GetFileName(): Security checks
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core.c b/src/core.c
index 9e26a639..44ac12b5 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1838,9 +1838,10 @@ static const char *strprbrk(const char *s, const char *charset)
// Get pointer to filename for a path string
const char *GetFileName(const char *filePath)
{
- const char *fileName = strprbrk(filePath, "\\/");
+ const char *fileName = NULL;
+ if (filePath != NULL) fileName = strprbrk(filePath, "\\/");
- if (!fileName || fileName == filePath) return filePath;
+ if (!fileName || (fileName == filePath)) return filePath;
return fileName + 1;
}
@@ -1853,7 +1854,7 @@ const char *GetFileNameWithoutExt(const char *filePath)
static char fileName[MAX_FILENAMEWITHOUTEXT_LENGTH];
memset(fileName, 0, MAX_FILENAMEWITHOUTEXT_LENGTH);
- strcpy(fileName, GetFileName(filePath)); // Get filename with extension
+ if (filePath != NULL) strcpy(fileName, GetFileName(filePath)); // Get filename with extension
int len = strlen(fileName);