Commit 3b11acf3 authored by deuce's avatar deuce
Browse files

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

parent dff20fb0
......@@ -882,16 +882,20 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) {
if(*path != '/') {
if(*path == '~') {
p=getenv("HOME");
if(p==NULL || strlen(p)+strlen(path)>=size)
if(p==NULL || strlen(p)+strlen(path)>=size) {
free(target);
return(NULL);
}
strcpy(target,p);
out=strrchr(target,'\0');
path++;
}
else {
p=getcwd(NULL,size);
if(p==NULL || strlen(p)+strlen(path)>=size)
if(p==NULL || strlen(p)+strlen(path)>=size) {
free(target);
return(NULL);
}
strcpy(target,p);
free(p);
out=strrchr(target,'\0');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment