From e9f5948d58b9fcef9ce04212d7e21c204034cc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 25 Mar 2007 22:42:37 +0000 Subject: [PATCH] Allocate enough memory to copy string See issue #2107 for more details. svn path=/trunk/; revision=26176 --- reactos/base/shell/cmd/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reactos/base/shell/cmd/dir.c b/reactos/base/shell/cmd/dir.c index 59cdc718c92..b27619a1e00 100644 --- a/reactos/base/shell/cmd/dir.c +++ b/reactos/base/shell/cmd/dir.c @@ -568,11 +568,11 @@ DirReadParam(LPTSTR Line, /* [IN] The line with the parameters & switches */ } /* Terminate the parameters */ if(ptrStart && ptrEnd) - { - temp = malloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR)); + { + temp = malloc((ptrEnd - ptrStart + 2) * sizeof(TCHAR)); if(!temp) return FALSE; - memcpy(temp, ptrStart, (ptrEnd - ptrStart) + 2 * sizeof (TCHAR)); + memcpy(temp, ptrStart, (ptrEnd - ptrStart + 1) * sizeof(TCHAR)); temp[(ptrEnd - ptrStart + 1)] = _T('\0'); if(!add_entry(entries, params, temp)) {