Don't leak dir on error path.
This commit is contained in:
parent
7fab839c75
commit
541dba3a78
|
@ -45,13 +45,16 @@ void * FsReadFirst(const char * path, FsEntry * entry) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tmp = opendir(path);
|
tmp = opendir(path);
|
||||||
if (!tmp)
|
if (!tmp) {
|
||||||
|
free(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
dir->dir = tmp;
|
dir->dir = tmp;
|
||||||
|
|
||||||
e = readdir(tmp);
|
e = readdir(tmp);
|
||||||
if (!e) {
|
if (!e) {
|
||||||
closedir(tmp);
|
closedir(tmp);
|
||||||
|
free(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(entry->cFileName, e->d_name);
|
strcpy(entry->cFileName, e->d_name);
|
||||||
|
|
Loading…
Reference in New Issue