if (lstat(pFileSearch->lpPath, &fileStat) < 0)
{
- free(pFileSearch);
+ FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* stat error */
}
if (S_ISDIR(fileStat.st_mode) == 0)
{
- free(pFileSearch);
+ FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* not a directory */
}
if (!pFileSearch->pDir)
{
- free(pFileSearch);
+ FindClose(pFileSearch);
return INVALID_HANDLE_VALUE; /* failed to open directory */
}
}
}
- free(pFileSearch);
+ FindClose(pFileSearch);
return INVALID_HANDLE_VALUE;
}
pFileSearch = (WIN32_FILE_SEARCH*) hFindFile;
- free(pFileSearch->lpPath);
- free(pFileSearch->lpPattern);
- closedir(pFileSearch->pDir);
+ if (pFileSearch)
+ {
+ if (pFileSearch->lpPath)
+ free(pFileSearch->lpPath);
+ if (pFileSearch->lpPattern)
+ free(pFileSearch->lpPattern);
+ if (pFileSearch->pDir)
+ closedir(pFileSearch->pDir);
+ free(pFileSearch);
- free(pFileSearch);
+ return TRUE;
+ }
- return TRUE;
+ return FALSE;
}
BOOL CreateDirectoryA(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)