TCHAR cDrive;
TCHAR szPath[MAX_PATH];
TCHAR szFilespec[MAX_PATH];
- LPTSTR* params;
+ LPTSTR* params = NULL;
INT entries = 0;
UINT loop = 0;
DIRSWITCHFLAGS stFlags;
+ INT ret = 1;
/* Initialize variables */
cDrive = 0;
if (!DirReadParam(dircmd, ¶ms, &entries, &stFlags))
{
nErrorLevel = 1;
- return 1;
+ goto cleanup;
}
/* read the parameters */
if (!DirReadParam(rest, ¶ms, &entries, &stFlags) || CheckCtrlBreak(BREAK_INPUT))
{
nErrorLevel = 1;
- return 1;
+ goto cleanup;
}
/* default to current directory */
if(entries == 0) {
if(!add_entry(&entries, ¶ms, _T("."))) {
nErrorLevel = 1;
- return 1;
+ goto cleanup;
}
}
if (DirParsePathspec (params[loop], szPath, szFilespec) || CheckCtrlBreak(BREAK_INPUT))
{
nErrorLevel = 1;
- return 1;
+ goto cleanup;
}
/* <Debug :>
if(cDrive != szPath[0] && !stFlags.bBareFormat) {
if (!PrintDirectoryHeader (szPath, &stFlags)) {
nErrorLevel = 1;
- return 1;
+ goto cleanup;
}
cDrive = szPath[0];
if (DirList (szPath, szFilespec, &stFlags))
{
nErrorLevel = 1;
- return 1;
+ goto cleanup;
}
}
recurse_dir_cnt,
recurse_bytes,
&stFlags);
-
- return 0;
+
+ ret = 0;
+
+cleanup:
+ freep(params);
+
+ return ret;
}
#endif