Re: [FFmpeg-devel] [PATCH 15/30] avcodec/ivi: Fix segfault on allocation error

2020-09-15 Thread Paul B Mahol
On Tue, Sep 15, 2020 at 09:39:45AM +0200, Andreas Rheinhardt wrote:
> If allocating the tiles array for indeo 4/5 fails, the context is in an
> inconsistent state, because the counter for the number of tiles is > 0.
> This will lead to a segfault when freeing the tiles' substructures.
> Fix this by setting the number of tiles to zero if the allocation was
> unsuccessfull.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/ivi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 

looks ok
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 15/30] avcodec/ivi: Fix segfault on allocation error

2020-09-15 Thread Andreas Rheinhardt
If allocating the tiles array for indeo 4/5 fails, the context is in an
inconsistent state, because the counter for the number of tiles is > 0.
This will lead to a segfault when freeing the tiles' substructures.
Fix this by setting the number of tiles to zero if the allocation was
unsuccessfull.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ivi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index c5c50fb5c1..c10984e83e 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -442,8 +442,10 @@ av_cold int ff_ivi_init_tiles(IVIPlaneDesc *planes,
 
 av_freep(&band->tiles);
 band->tiles = av_mallocz_array(band->num_tiles, sizeof(IVITile));
-if (!band->tiles)
+if (!band->tiles) {
+band->num_tiles = 0;
 return AVERROR(ENOMEM);
+}
 
 /* use the first luma band as reference for motion vectors
  * and quant */
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".