Skip to content

Commit f6a2447

Browse files
Filip Roséentguillem
authored andcommitted
stream_filter/cache_block: fix premature EOF
AStreamReadBlock would potentially return 0 because the current data block (denoted by "p_sys->p_current") was exhausted, even though there might be more data in the next data block ("p_sys->p_current->p_next"). At the place where this patch apply, `p_sys->p_current` has been set to `p_sys->p_current->p_next`, so the pointer denotes the next block to process (even though the name is rather misleading at that point). Signed-off-by: Thomas Guillem <[email protected]>
1 parent b1a9cc9 commit f6a2447

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/stream_filter/cache_block.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,16 @@ static ssize_t AStreamReadBlock(stream_t *s, void *buf, size_t len)
402402
AStreamRefillBlock(s);
403403
}
404404

405+
/**
406+
* we should not signal end-of-file if we have not exhausted
407+
* the blocks we know about, as such we should try again if that
408+
* is the case. i_copy == 0 just means that the processed block does
409+
* not contain data at the offset that we want, not EOF.
410+
**/
411+
412+
if( i_copy == 0 && sys->p_current )
413+
return AStreamReadBlock( s, buf, len );
414+
405415
sys->i_pos += i_copy;
406416
return i_copy;
407417
}

0 commit comments

Comments
 (0)