Commit be5d66f5 authored by Andrew Nguyen's avatar Andrew Nguyen Committed by Alexandre Julliard

krnl386.exe: Fix a potential leak and NULL dereference in DPMI_xrealloc.

parent ea7bcc6c
......@@ -266,11 +266,11 @@ static void DPMI_xfree( LPVOID ptr )
static LPVOID DPMI_xrealloc( LPVOID ptr, DWORD newsize )
{
MEMORY_BASIC_INFORMATION mbi;
LPVOID newptr;
newptr = DPMI_xalloc( newsize );
if (ptr)
{
LPVOID newptr;
if (!VirtualQuery(ptr,&mbi,sizeof(mbi)))
{
FIXME( "realloc of DPMI_xallocd region %p?\n", ptr );
......@@ -289,11 +289,17 @@ static LPVOID DPMI_xrealloc( LPVOID ptr, DWORD newsize )
if (newsize <= mbi.RegionSize)
return ptr;
newptr = DPMI_xalloc( newsize );
if (!newptr)
return NULL;
memcpy( newptr, ptr, mbi.RegionSize );
DPMI_xfree( ptr );
}
return newptr;
}
return DPMI_xalloc( newsize );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment