Allocate correct amount of memory.

See issue #2499 for more details.

svn path=/trunk/; revision=28066
This commit is contained in:
Thomas Bluemel 2007-08-01 10:39:49 +00:00
parent df91a99233
commit fc6d0b3bc7

View file

@ -364,10 +364,10 @@ DirReadParam(LPTSTR Line, /* [IN] The line with the parameters & switches */
cCurSwitch = _T(' ');
if(ptrStart && ptrEnd)
{
temp = cmd_alloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
temp = cmd_alloc(((ptrEnd - ptrStart) + 2) * sizeof (TCHAR));
if(!temp)
return FALSE;
memcpy(temp, ptrStart, (ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
memcpy(temp, ptrStart, ((ptrEnd - ptrStart) + 2) * sizeof (TCHAR));
temp[(ptrEnd - ptrStart + 1)] = _T('\0');
if(!add_entry(entries, params, temp))
{
@ -396,10 +396,10 @@ DirReadParam(LPTSTR Line, /* [IN] The line with the parameters & switches */
/* Process a character for parameter */
if ((cCurSwitch == _T(' ')) && ptrStart && ptrEnd)
{
temp = cmd_alloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
temp = cmd_alloc(((ptrEnd - ptrStart) + 2) * sizeof (TCHAR));
if(!temp)
return FALSE;
memcpy(temp, ptrStart, (ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
memcpy(temp, ptrStart, ((ptrEnd - ptrStart) + 2) * sizeof (TCHAR));
temp[(ptrEnd - ptrStart + 1)] = _T('\0');
if(!add_entry(entries, params, temp))
{