decoder: check length==0 in decoder_read()

When the caller passes length==0, decoder_read() entered an endless
loop.  Check that condition before entering the "while" loop.
This commit is contained in:
Max Kellermann
2008-11-15 19:27:30 +01:00
parent c368a2f91c
commit acfba02310
2 changed files with 7 additions and 0 deletions

View File

@@ -106,6 +106,9 @@ size_t decoder_read(struct decoder *decoder,
assert(is != NULL);
assert(buffer != NULL);
if (length == 0)
return 0;
while (true) {
/* XXX don't allow decoder==NULL */
if (decoder != NULL &&