From: Thomas Faber Date: Fri, 28 Aug 2015 10:51:10 +0000 (+0000) Subject: [CMD] X-Git-Tag: ReactOS-0.4.0~1179 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=4e5f69d4d19fe2e3ff88494f4c66100ca7e39301 [CMD] - In DirList, initialize stInfo.ptrHead of the dummy node to avoid invalid memory access. Fixes regression in cmd:batch svn path=/trunk/; revision=68846 --- diff --git a/reactos/base/shell/cmd/dir.c b/reactos/base/shell/cmd/dir.c index 8ae1447a761..0e80a24e27b 100644 --- a/reactos/base/shell/cmd/dir.c +++ b/reactos/base/shell/cmd/dir.c @@ -1376,6 +1376,7 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ WARN("DEBUG: Cannot allocate memory for ptrStartNode!\n"); return 1; /* Error cannot allocate memory for 1st object */ } + ptrStartNode->stInfo.ptrHead = NULL; ptrNextNode = ptrStartNode; /*Checking ir szPath is a File with/wout extension*/ @@ -1478,8 +1479,8 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ ptrCurNode = &(*ptrCurNode)->ptrNext; } - FindClose(hStreams); - *ptrCurNode = NULL; + FindClose(hStreams); + *ptrCurNode = NULL; } } @@ -1538,12 +1539,12 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */ dwCount = 0; while (ptrNextNode->ptrNext) { - *(ptrFileArray + dwCount) = &ptrNextNode->ptrNext->stInfo; + ptrFileArray[dwCount] = &ptrNextNode->ptrNext->stInfo; ptrNextNode = ptrNextNode->ptrNext; dwCount++; } - /* Sort Data if requested*/ + /* Sort Data if requested */ if (lpFlags->stOrderBy.sCriteriaCount > 0) QsortFiles(ptrFileArray, 0, dwCount-1, lpFlags);