projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5ac5464
)
fixed bug that may lead to free()ing static memory
author
Holger Schemel
<info@artsoft.org>
Tue, 7 Nov 2017 21:55:42 +0000
(22:55 +0100)
committer
Holger Schemel
<info@artsoft.org>
Fri, 23 Mar 2018 22:21:15 +0000
(23:21 +0100)
src/libgame/misc.c
patch
|
blob
|
history
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index 72e4f051bf47a44f17b66d28be20fa693e151274..3ff1f8aa9c269d18e84b4bcb8ecf9d806287acd3 100644
(file)
--- a/
src/libgame/misc.c
+++ b/
src/libgame/misc.c
@@
-682,10
+682,16
@@
char *getBasePath(char *filename)
char *basepath = getStringCopy(filename);
char *last_separator = getLastPathSeparatorPtr(basepath);
char *basepath = getStringCopy(filename);
char *last_separator = getLastPathSeparatorPtr(basepath);
- if (last_separator != NULL)
- *last_separator = '\0'; /* separator found: strip basename */
- else
- basepath = "."; /* no separator found: use current path */
+ /* if no separator was found, use current directory */
+ if (last_separator == NULL)
+ {
+ free(basepath);
+
+ return getStringCopy(".");
+ }
+
+ /* separator found: strip basename */
+ *last_separator = '\0';
return basepath;
}
return basepath;
}