[ros-diffs] [hpoussin] 26176: Allocate enough memory to copy string See issue #2107 for more details.

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Mon Mar 26 00:42:37 CEST 2007


Author: hpoussin
Date: Mon Mar 26 02:42:37 2007
New Revision: 26176

URL: http://svn.reactos.org/svn/reactos?rev=26176&view=rev
Log:
Allocate enough memory to copy string
See issue #2107 for more details.

Modified:
    trunk/reactos/base/shell/cmd/dir.c

Modified: trunk/reactos/base/shell/cmd/dir.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/dir.c?rev=26176&r1=26175&r2=26176&view=diff
==============================================================================
--- trunk/reactos/base/shell/cmd/dir.c (original)
+++ trunk/reactos/base/shell/cmd/dir.c Mon Mar 26 02:42:37 2007
@@ -568,11 +568,11 @@
 	}
 	/* 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))
 		{




More information about the Ros-diffs mailing list