winpr/stream: don't allow 0-size streams

This commit is contained in:
Bernhard Miklautz 2015-10-23 18:06:17 +02:00
parent a9d81ad083
commit ab05a79c21
2 changed files with 15 additions and 0 deletions

View File

@ -70,6 +70,9 @@ wStream* Stream_New(BYTE* buffer, size_t size)
{
wStream* s;
if (!buffer && !size)
return NULL;
s = malloc(sizeof(wStream));
if (!s)

View File

@ -65,6 +65,16 @@ static BOOL TestStream_Verify(wStream* s, int mincap, int len, int pos)
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)
{
@ -266,6 +276,8 @@ int TestStream(int argc, char* argv[])
if (!TestStream_Reading())
return 4;
if (!TestStream_New())
return 5;
/**
* FIXME: Add tests for
* Stream_Write_*