[FFmpeg-cvslog] avcodec/hashtable: Zero-initialize hashtable

Andreas Rheinhardt git at videolan.org
Wed Jun 4 16:40:53 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Jun  3 21:42:24 2025 +0200| [2fc310b2f25f9a803c9d5603e2efda384b3f1add] | committer: Andreas Rheinhardt

avcodec/hashtable: Zero-initialize hashtable

Otherwise ff_hashtable_freep() would try to free uninitialized
pointers upon allocation error (which happens in the corresponding
test tool).

Reviewed-by: Emma Worley <emma at emma.gg>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2fc310b2f25f9a803c9d5603e2efda384b3f1add
---

 libavcodec/hashtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/hashtable.c b/libavcodec/hashtable.c
index 151476176b..4c7d3e18ba 100644
--- a/libavcodec/hashtable.c
+++ b/libavcodec/hashtable.c
@@ -58,7 +58,7 @@ struct FFHashtableContext {
 
 int ff_hashtable_alloc(struct FFHashtableContext **ctx, size_t key_size, size_t val_size, size_t max_entries)
 {
-    struct FFHashtableContext *res = av_malloc(sizeof(struct FFHashtableContext));
+    FFHashtableContext *res = av_mallocz(sizeof(*res));
     if (!res)
         return AVERROR(ENOMEM);
     res->key_size = key_size;



More information about the ffmpeg-cvslog mailing list