summaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_libopencv.c
diff options
context:
space:
mode:
authorSteven Liu <lq@chinaffmpeg.org>2017-01-11 09:59:55 +0800
committerSteven Liu <lq@chinaffmpeg.org>2017-01-11 09:59:55 +0800
commit184c13f64aa5dda7af648cfd8302df3ef8afacc7 (patch)
tree883550920041154129a8bde9dcc76b6b34def88b /libavfilter/vf_libopencv.c
parent658e626cc0d5de2d663f0e69c8836a87f51dd39f (diff)
downloadffmpeg-streaming-184c13f64aa5dda7af648cfd8302df3ef8afacc7.zip
ffmpeg-streaming-184c13f64aa5dda7af648cfd8302df3ef8afacc7.tar.gz
avfilter/vf_libopencv: fix resource leak in read_shape_frame_filter
CID: 1324298 add a label when error goto the label to release resource Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Diffstat (limited to 'libavfilter/vf_libopencv.c')
-rw-r--r--libavfilter/vf_libopencv.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index f8ae9d5..8128030 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -157,7 +157,8 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
if (buf[i] == '\n') {
if (*rows == INT_MAX) {
av_log(log_ctx, AV_LOG_ERROR, "Overflow on the number of rows in the file\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
}
++(*rows);
*cols = FFMAX(*cols, w);
@@ -171,10 +172,13 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
if (*rows > (SIZE_MAX / sizeof(int) / *cols)) {
av_log(log_ctx, AV_LOG_ERROR, "File with size %dx%d is too big\n",
*rows, *cols);
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
+ }
+ if (!(*values = av_mallocz_array(sizeof(int) * *rows, *cols))) {
+ ret = AVERROR(ENOMEM);
+ goto end;
}
- if (!(*values = av_mallocz_array(sizeof(int) * *rows, *cols)))
- return AVERROR(ENOMEM);
/* fill *values */
p = buf;
@@ -188,6 +192,8 @@ static int read_shape_from_file(int *cols, int *rows, int **values, const char *
(*values)[*cols*i + j] = !!av_isgraph(*(p++));
}
}
+
+end:
av_file_unmap(buf, size);
#ifdef DEBUG
OpenPOWER on IntegriCloud