Skip to content
Snippets Groups Projects
Commit 3b11acf3 authored by deuce's avatar deuce
Browse files

Fix memory leak when the UNIX _fullpath() returns NULL.

parent dff20fb0
No related branches found
No related tags found
No related merge requests found
...@@ -882,16 +882,20 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) { ...@@ -882,16 +882,20 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) {
if(*path != '/') { if(*path != '/') {
if(*path == '~') { if(*path == '~') {
p=getenv("HOME"); p=getenv("HOME");
if(p==NULL || strlen(p)+strlen(path)>=size) if(p==NULL || strlen(p)+strlen(path)>=size) {
free(target);
return(NULL); return(NULL);
}
strcpy(target,p); strcpy(target,p);
out=strrchr(target,'\0'); out=strrchr(target,'\0');
path++; path++;
} }
else { else {
p=getcwd(NULL,size); p=getcwd(NULL,size);
if(p==NULL || strlen(p)+strlen(path)>=size) if(p==NULL || strlen(p)+strlen(path)>=size) {
free(target);
return(NULL); return(NULL);
}
strcpy(target,p); strcpy(target,p);
free(p); free(p);
out=strrchr(target,'\0'); out=strrchr(target,'\0');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment