summaryrefslogtreecommitdiff
path: root/libavformat/hevc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-01-23 17:08:29 +0100
committerJames Almer <jamrial@gmail.com>2020-01-26 12:41:31 -0300
commit680cd59bb21c7bce92789ff885c018207b0b90bc (patch)
treeb62b075c3303b0e9d4e6a74db05d4ef2e8edc24b /libavformat/hevc.c
parente4749a44979e8d403021d265623e9233fee0dae4 (diff)
avformat/hevc: Fix potential leak in case of ff_hevc_annexb2mp4_buf failure
ff_hevc_annexb2mp4_buf() could indicate an error, yet leave cleaning after itself to the caller, so that a caller could not simply return the error, but had to free the buffer first. (Given that all current callers have set filter_ps = 0, this error can currently not be triggered.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/hevc.c')
-rw-r--r--libavformat/hevc.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavformat/hevc.c b/libavformat/hevc.c
index c7c4be3441..db931d2017 100644
--- a/libavformat/hevc.c
+++ b/libavformat/hevc.c
@@ -25,6 +25,7 @@
#include "libavutil/intreadwrite.h"
#include "avc.h"
#include "avio.h"
+#include "avio_internal.h"
#include "hevc.h"
#define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field
@@ -1054,6 +1055,11 @@ int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
return ret;
ret = ff_hevc_annexb2mp4(pb, buf_in, *size, filter_ps, ps_count);
+ if (ret < 0) {
+ ffio_free_dyn_buf(&pb);
+ return ret;
+ }
+
*size = avio_close_dyn_buf(pb, buf_out);
return ret;