aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_hwmap.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-06-16 23:11:51 +0100
committerMark Thompson <sw@jkqxz.net>2017-06-18 17:06:41 +0100
commit70808859ddf4c636472b56f5ec637c4754276867 (patch)
treec3785cef777a51ef56fa36ac4571db9a40fbed3f /libavfilter/vf_hwmap.c
parentd984b29b21f6442fb6a809c08c07533dd496b1f9 (diff)
downloadffmpeg-70808859ddf4c636472b56f5ec637c4754276867.tar.gz
vf_hwmap: Properly free a locally derived device
Fixes CID 1412853. (cherry picked from commit a670eea56087d0ecd4fbeccf3a9beb9110b7031f)
Diffstat (limited to 'libavfilter/vf_hwmap.c')
-rw-r--r--libavfilter/vf_hwmap.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavfilter/vf_hwmap.c b/libavfilter/vf_hwmap.c
index 4f6f69a7aa..8277241dc4 100644
--- a/libavfilter/vf_hwmap.c
+++ b/libavfilter/vf_hwmap.c
@@ -58,7 +58,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
AVHWFramesContext *hwfc;
AVBufferRef *device;
const AVPixFmtDescriptor *desc;
- int err;
+ int err, device_is_derived;
av_log(avctx, AV_LOG_DEBUG, "Configure hwmap %s -> %s.\n",
av_get_pix_fmt_name(inlink->format),
@@ -67,6 +67,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
av_buffer_unref(&ctx->hwframes_ref);
device = avctx->hw_device_ctx;
+ device_is_derived = 0;
if (inlink->hw_frames_ctx) {
hwfc = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
@@ -88,6 +89,7 @@ static int hwmap_config_output(AVFilterLink *outlink)
"device context: %d.\n", err);
goto fail;
}
+ device_is_derived = 1;
}
desc = av_pix_fmt_desc_get(outlink->format);
@@ -242,9 +244,13 @@ static int hwmap_config_output(AVFilterLink *outlink)
outlink->w = inlink->w;
outlink->h = inlink->h;
+ if (device_is_derived)
+ av_buffer_unref(&device);
return 0;
fail:
+ if (device_is_derived)
+ av_buffer_unref(&device);
av_buffer_unref(&ctx->hwframes_ref);
return err;
}