The function can fail internally and using the returned context results
in segfaults.
---
libavcodec/get_bits.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index c56a2c2..e1d64c9 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -367,13 +367,15 @@ static inline int check_marker(GetBitContext *s, const
char *msg)
* because some optimized bitstream readers read 32 or 64 bit at once and
could read over the end
* @param bit_size the size of the buffer in bits
*/
-static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer,
+static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
int bit_size)
{
int buffer_size = (bit_size+7)>>3;
+ int ret = 0;
if (buffer_size < 0 || bit_size < 0) {
buffer_size = bit_size = 0;
buffer = NULL;
+ ret = AVERROR_INVALIDDATA;
}
s->buffer = buffer;
@@ -383,6 +385,7 @@ static inline void init_get_bits(GetBitContext *s, const
uint8_t *buffer,
#endif
s->buffer_end = buffer + buffer_size;
s->index = 0;
+ return ret;
}
static inline void align_get_bits(GetBitContext *s)
--
1.8.0.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel