This prevents possible infinite loops with the calling code along the lines of while (bytestream2_get_bytes_left()) { ... }, where the reader does not advance.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -70,8 +70,10 @@ static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \ · 69 unmodified lines | ||
| 70 | 70 | } \ |
| 71 | 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 | 75 | return 0; \ |
| 76 | + } \ | |
| 75 | 77 | return bytestream2_get_ ## name ## u(g); \ |
| 76 | 78 | } \ |
| 77 | 79 | static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \ |