This prevents possible infinite loops with the calling code along the lines of while (bytestream2_get_bytes_left()) { ... }, where the reader does not advance.
Unified · Split
| @@ -70,8 +70,10 @@ static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \ · 69 unmodified lines | |||
| 70 | } \ | 70 | } \ |
| 71 | static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \ | 71 | static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \ |
| 72 | { \ | 72 | { \ |
| 73 | if (g->buffer_end - g->buffer < bytes) \ | 73 | if (g->buffer_end - g->buffer < bytes) { \ |
| 74 | g->buffer = g->buffer_end; \ | ||
| 74 | return 0; \ | 75 | return 0; \ |
| 76 | } \ | ||
| 75 | return bytestream2_get_ ## name ## u(g); \ | 77 | return bytestream2_get_ ## name ## u(g); \ |
| 76 | } \ | 78 | } \ |
| 77 | static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \ | 79 | static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \ |