[FFmpeg-devel] [PATCH] fix mem-leak
Danil Iashchenko
danyaschenko at gmail.com
Mon Mar 12 08:30:55 EET 2018
---
libavfilter/vf_convolution_opencl.c | 39 ++++++++++++++-----------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/libavfilter/vf_convolution_opencl.c b/libavfilter/vf_convolution_opencl.c
index 60e2d1f..a14005b 100644
--- a/libavfilter/vf_convolution_opencl.c
+++ b/libavfilter/vf_convolution_opencl.c
@@ -139,7 +139,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
matrix = av_malloc(matrix_bytes);
if (!matrix) {
err = AVERROR(ENOMEM);
- goto fail;
+ goto fail_matrix;
}
cnt = 0;
for (i = 0; i < 4; i++) {
@@ -157,7 +157,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Failed to create matrix buffer: "
"%d.\n", cle);
err = AVERROR(EIO);
- goto fail;
+ goto fail_matrix;
}
ctx->matrix = buffer;
@@ -166,8 +166,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
matrix_rdiv = av_malloc(matrix_bytes);
if (!matrix_rdiv) {
err = AVERROR(ENOMEM);
- av_freep(&matrix_rdiv);
- goto fail;
+ goto fail_rdiv;
}
for (j = 0; j < 4; j++) {
@@ -182,8 +181,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Failed to create rdiv buffer: "
"%d.\n", cle);
err = AVERROR(EIO);
- av_freep(&matrix_rdiv);
- goto fail;
+ goto fail_rdiv;
}
ctx->rdiv_buffer = buffer_rdiv;
@@ -192,9 +190,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
matrix_bias = av_malloc(matrix_bytes);
if (!matrix_bias) {
err = AVERROR(ENOMEM);
- av_freep(&matrix_rdiv);
- av_freep(&matrix_bias);
- goto fail;
+ goto fail_bias;
}
for (j = 0; j < 4; j++) {
@@ -209,9 +205,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Failed to create bias buffer: "
"%d.\n", cle);
err = AVERROR(EIO);
- av_freep(&matrix_rdiv);
- av_freep(&matrix_bias);
- goto fail;
+ goto fail_bias;
}
ctx->bias_buffer = buffer_bias;
@@ -219,10 +213,7 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
matrix_size = av_malloc(matrix_bytes);
if (!matrix_size) {
err = AVERROR(ENOMEM);
- av_freep(&matrix_rdiv);
- av_freep(&matrix_bias);
- av_freep(&matrix_size);
- goto fail;
+ goto fail_size;
}
for (j = 0; j < 4; j++) {
@@ -237,18 +228,18 @@ static int convolution_opencl_make_filter_params(AVFilterContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Failed to create bias buffer: "
"%d.\n", cle);
err = AVERROR(EIO);
- av_freep(&matrix_rdiv);
- av_freep(&matrix_bias);
- av_freep(&matrix_size);
- goto fail;
+ goto fail_size;
}
ctx->size_buffer = buffer_size;
-
-
-
err = 0;
-fail:
+fail_size:
+ av_freep(&matrix_size);
+fail_bias:
+ av_freep(&matrix_bias);
+fail_rdiv:
+ av_freep(&matrix_rdiv);
+fail_matrix:
av_freep(&matrix);
return err;
}
--
2.7.4
More information about the ffmpeg-devel
mailing list