winpr/stream: don't allow 0-size streams
This commit is contained in:
parent
a9d81ad083
commit
ab05a79c21
@ -70,6 +70,9 @@ wStream* Stream_New(BYTE* buffer, size_t size)
|
|||||||
{
|
{
|
||||||
wStream* s;
|
wStream* s;
|
||||||
|
|
||||||
|
if (!buffer && !size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
s = malloc(sizeof(wStream));
|
s = malloc(sizeof(wStream));
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
|
@ -65,6 +65,16 @@ static BOOL TestStream_Verify(wStream* s, int mincap, int len, int pos)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL TestStream_New()
|
||||||
|
{
|
||||||
|
wStream *s = NULL;
|
||||||
|
/* Test creation of a 0-size stream with no buffer */
|
||||||
|
s = Stream_New(NULL, 0);
|
||||||
|
if (s)
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL TestStream_Create(int count, BOOL selfAlloc)
|
static BOOL TestStream_Create(int count, BOOL selfAlloc)
|
||||||
{
|
{
|
||||||
@ -266,6 +276,8 @@ int TestStream(int argc, char* argv[])
|
|||||||
if (!TestStream_Reading())
|
if (!TestStream_Reading())
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
|
if (!TestStream_New())
|
||||||
|
return 5;
|
||||||
/**
|
/**
|
||||||
* FIXME: Add tests for
|
* FIXME: Add tests for
|
||||||
* Stream_Write_*
|
* Stream_Write_*
|
||||||
|
Loading…
Reference in New Issue
Block a user