On Thu, Apr 09, 2015 at 11:48:44AM +0200, Vittorio Giovara wrote:
> ---
> libavcodec/ffv1.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
> index d1a6a83..1a02cf8 100644
> --- a/libavcodec/ffv1.c
> +++ b/libavcodec/ffv1.c
> @@ -204,6 +204,8 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
> int sys = f->avctx->height * sy / f->num_v_slices;
> int sye = f->avctx->height * (sy + 1) / f->num_v_slices;
> f->slice_context[i] = fs;
> + if (!f->slice_context[i])
> + goto memfail;
I'd consider it more readable if you move the malloc below the assignments
and checked it in the next line instead of this indirection.
> @@ -215,9 +217,17 @@ av_cold int ffv1_init_slice_contexts(FFV1Context *f)
> +memfail:
> + for (i = 0; i < f->slice_count; i++) {
> + if (!f->slice_context[i])
> + continue;
> + av_freep(&f->slice_context[i]->sample_buffer);
> + av_freep(&f->slice_context[i]);
> + }
> + return AVERROR(ENOMEM);
> }
You don't have to blindly try to free everything. You still have the
counter value for which it failed, so just free the successful allocations
for counter values below the failing one.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel