diff --git a/desmume/src/fs-linux.cpp b/desmume/src/fs-linux.cpp index 645cda0e0..27039d9ef 100644 --- a/desmume/src/fs-linux.cpp +++ b/desmume/src/fs-linux.cpp @@ -45,13 +45,16 @@ void * FsReadFirst(const char * path, FsEntry * entry) { return NULL; tmp = opendir(path); - if (!tmp) + if (!tmp) { + free(dir); return NULL; + } dir->dir = tmp; e = readdir(tmp); if (!e) { closedir(tmp); + free(dir); return NULL; } strcpy(entry->cFileName, e->d_name);