Fixed missing check before calling memcpy

This commit is contained in:
Armin Novak 2018-08-23 12:43:29 +02:00
parent 0fb19d04be
commit c159b2e9c8

View File

@ -216,8 +216,11 @@ static INLINE void Stream_Write_UINT64(wStream* _s, UINT64 _v)
}
static INLINE void Stream_Write(wStream* _s, const void* _b, size_t _n)
{
memcpy(_s->pointer, (_b), (_n));
Stream_Seek(_s, _n);
if (_n > 0)
{
memcpy(_s->pointer, (_b), (_n));
Stream_Seek(_s, _n);
}
}
#define Stream_Seek_UINT8(_s) Stream_Seek(_s, 1)
@ -342,7 +345,7 @@ static INLINE BOOL Stream_Read_UTF16_String(wStream* s, WCHAR* dst, size_t lengt
if (Stream_GetRemainingLength(s) / sizeof(WCHAR) < length)
return FALSE;
for (x=0; x<length; x++)
for (x = 0; x < length; x++)
Stream_Read_UINT16(s, dst[x]);
return TRUE;
@ -358,7 +361,7 @@ static INLINE BOOL Stream_Write_UTF16_String(wStream* s, const WCHAR* src, size_
if (Stream_GetRemainingCapacity(s) / sizeof(WCHAR) < length)
return FALSE;
for (x=0; x<length; x++)
for (x = 0; x < length; x++)
Stream_Write_UINT16(s, src[x]);
return TRUE;