X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_libopencv.c;h=8128030b8c9b7827af3ffabcf2f07d6f17eead70;hb=647af1a0dd2e1ea880790df0c3047cb44c3cd53b;hp=f8ae9d5a6dad04cc56b09ac11b6bd3c095ada327;hpb=25004c7e6eaa91c749763c1dabb41c4fc9c692e2;p=ffmpeg diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index f8ae9d5a6da..8128030b8c9 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