[FFmpeg-devel] [PATCH 3/4] hwcontext: Don't segfault on invalid arguments to transfer
Mark Thompson
sw at jkqxz.net
Tue May 22 01:35:10 EEST 2018
The code previously assumed that src->hw_frames_ctx was necessarily set
if dst->buf wasn't. Using non-refcounted hardware frames is not allowed
here, but we can return an error in that case.
---
libavutil/hwcontext.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 745016ed7e..5859443cf6 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -441,8 +441,12 @@ int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
AVHWFramesContext *ctx;
int ret;
- if (!dst->buf[0])
- return transfer_data_alloc(dst, src, flags);
+ if (!dst->buf[0]) {
+ if (src->hw_frames_ctx)
+ return transfer_data_alloc(dst, src, flags);
+ else
+ return AVERROR(EINVAL);
+ }
if (src->hw_frames_ctx) {
ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
--
2.16.3
More information about the ffmpeg-devel
mailing list