History

bytestream2: set the reader to the end when reading more than available

This prevents possible infinite loops with the calling code along the lines of while (bytestream2_get_bytes_left()) { ... }, where the reader does not advance.

Anton Khirnov committed 11 years ago

Commit 86eee851 parent 8bc67ec1 file · +3 −1Browse files

Showing the changes to libavcodec/bytestream.h (1 of 1 file). Show all

Unified · Split

libavcodec/bytestream.h+3−1
@@ -70,8 +70,10 @@ static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \ · 69 unmodified lines
7070 } \
7171 static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \
7272 { \
73− if (g->buffer_end - g->buffer < bytes) \
73+ if (g->buffer_end - g->buffer < bytes) { \
74+ g->buffer = g->buffer_end; \
7475 return 0; \
76+ } \
7577 return bytestream2_get_ ## name ## u(g); \
7678 } \
7779 static av_always_inline type bytestream2_peek_ ## name(GetByteContext *g) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t