mirror of
https://github.com/reactos/reactos.git
synced 2025-06-26 15:29:43 +00:00
Fix realloc behavior when size == 0 and ptr != NULL.
Patch by DrV, bug 2347. svn path=/trunk/; revision=27299
This commit is contained in:
parent
57e548bec4
commit
1289745bf8
1 changed files with 11 additions and 7 deletions
|
@ -73,18 +73,22 @@ void* realloc(void* _ptr, size_t _size)
|
||||||
{
|
{
|
||||||
size_t nSize;
|
size_t nSize;
|
||||||
|
|
||||||
if (( _size == 0) && (_ptr !=NULL))
|
if (_ptr == NULL)
|
||||||
|
return malloc(_size);
|
||||||
|
|
||||||
|
if (_size == 0)
|
||||||
|
{
|
||||||
|
free(_ptr);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
nSize = ROUND_SIZE(_size);
|
nSize = ROUND_SIZE(_size);
|
||||||
|
|
||||||
|
/* check for integer overflow */
|
||||||
if (nSize<_size)
|
if (nSize<_size)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_ptr) return malloc(_size);
|
return HeapReAlloc(hHeap, 0, _ptr, nSize);
|
||||||
if (_size) return HeapReAlloc(hHeap, 0, _ptr, nSize);
|
|
||||||
free(_ptr);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue