diff mbox

[FFmpeg-devel] avformat/aviobuf: initialize all checksum fields

Message ID 20180214005449.42974-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Feb. 14, 2018, 12:54 a.m. UTC
Calling ffio_ensure_seekback() right after initializing an AVIOContext
with ffio_init_context() would result in a use of uninitialised value.

Fixes fate-adts-id3v2-demux when using valgrind.

Signed-off-by: James Almer <jamrial@gmail.com>
---
Maybe we should do a memset(s, 0, sizeof(*s)) at the beginning of
ffio_init_context() instead, to effectively initialize every field to
zero. Which is prefered?

 libavformat/aviobuf.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Carl Eugen Hoyos Feb. 14, 2018, 12:08 p.m. UTC | #1
2018-02-14 1:54 GMT+01:00 James Almer <jamrial@gmail.com>:
> Calling ffio_ensure_seekback() right after initializing an AVIOContext
> with ffio_init_context() would result in a use of uninitialised value.
>
> Fixes fate-adts-id3v2-demux when using valgrind.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Maybe we should do a memset(s, 0, sizeof(*s)) at the beginning of
> ffio_init_context() instead, to effectively initialize every field to
> zero. Which is prefered?

Imo, a memset is more readable (and I suspect it makes it
less likely a compiler does something unreasonable).

Carl Eugen
diff mbox

Patch

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 86eb6579f4..a5ce9b9bf2 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -106,6 +106,8 @@  int ffio_init_context(AVIOContext *s,
     s->seekable        = seek ? AVIO_SEEKABLE_NORMAL : 0;
     s->min_packet_size = 0;
     s->max_packet_size = 0;
+    s->checksum        = 0;
+    s->checksum_ptr    = NULL;
     s->update_checksum = NULL;
     s->short_seek_threshold = SHORT_SEEK_THRESHOLD;