Message ID | AM7PR03MB6660AFD44566F1F3556426E78F2D9@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | Accepted |
Commit | 31da97b08325a338db7931428ba0625d4e61f168 |
Headers | show |
Series | [FFmpeg-devel,1/2] avcodec/vc2enc_dwt: Avoid NULL - 0 | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
Andreas Rheinhardt: > It is sane, but UB. It could happen in case of allocation errors > in vc2_encode_init(). > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavcodec/vc2enc_dwt.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/vc2enc_dwt.c b/libavcodec/vc2enc_dwt.c > index a8d3f1c669..441af040ec 100644 > --- a/libavcodec/vc2enc_dwt.c > +++ b/libavcodec/vc2enc_dwt.c > @@ -276,6 +276,8 @@ av_cold int ff_vc2enc_init_transforms(VC2TransformContext *s, int p_stride, > > av_cold void ff_vc2enc_free_transforms(VC2TransformContext *s) > { > - av_free(s->buffer - s->padding); > - s->buffer = NULL; > + if (s->buffer) { > + av_free(s->buffer - s->padding); > + s->buffer = NULL; > + } > } Will apply these patches later tonight unless there are objections. - Andreas
diff --git a/libavcodec/vc2enc_dwt.c b/libavcodec/vc2enc_dwt.c index a8d3f1c669..441af040ec 100644 --- a/libavcodec/vc2enc_dwt.c +++ b/libavcodec/vc2enc_dwt.c @@ -276,6 +276,8 @@ av_cold int ff_vc2enc_init_transforms(VC2TransformContext *s, int p_stride, av_cold void ff_vc2enc_free_transforms(VC2TransformContext *s) { - av_free(s->buffer - s->padding); - s->buffer = NULL; + if (s->buffer) { + av_free(s->buffer - s->padding); + s->buffer = NULL; + } }
It is sane, but UB. It could happen in case of allocation errors in vc2_encode_init(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/vc2enc_dwt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)