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

Fix last commit... only free() target if we malloc()ed it.

parent 3b11acf3
Branches
Tags
No related merge requests found
......@@ -870,11 +870,13 @@ ulong DLLCALL getdisksize(const char* path, ulong unit)
char * DLLCALL _fullpath(char *target, const char *path, size_t size) {
char *out;
char *p;
BOOL target_alloced=FALSE;
if(target==NULL) {
if((target=malloc(MAX_PATH+1))==NULL) {
return(NULL);
}
target_alloced=TRUE;
}
out=target;
*out=0;
......@@ -883,6 +885,7 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) {
if(*path == '~') {
p=getenv("HOME");
if(p==NULL || strlen(p)+strlen(path)>=size) {
if(target_alloced)
free(target);
return(NULL);
}
......@@ -893,6 +896,7 @@ char * DLLCALL _fullpath(char *target, const char *path, size_t size) {
else {
p=getcwd(NULL,size);
if(p==NULL || strlen(p)+strlen(path)>=size) {
if(target_alloced)
free(target);
return(NULL);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment