diff mbox series

[FFmpeg-devel] libswscale/utils.c: Fix bug #8255

Message ID 20200209183309.11939-1-gautamramk@gmail.com
State New
Headers show
Series [FFmpeg-devel] libswscale/utils.c: Fix bug #8255
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Gautam Ramakrishnan Feb. 9, 2020, 6:33 p.m. UTC
From: Gautam Ramakrishnan <gautamramk@gmail.com>

Bug #8255 points out a double free error in libwscale/utils.c file.
The double free is because the pointer to cascaded_context of an
sw_context is not set to NULL after freeing it. When the sw_context
is later freed, sws_freeContext is called on the cascaded_context,
causing a double free.
---
 libswscale/utils.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Michael Niedermayer Feb. 9, 2020, 8:25 p.m. UTC | #1
On Mon, Feb 10, 2020 at 12:03:09AM +0530, gautamramk@gmail.com wrote:
> From: Gautam Ramakrishnan <gautamramk@gmail.com>
> 
> Bug #8255 points out a double free error in libwscale/utils.c file.
> The double free is because the pointer to cascaded_context of an
> sw_context is not set to NULL after freeing it. When the sw_context
> is later freed, sws_freeContext is called on the cascaded_context,
> causing a double free.
> ---
>  libswscale/utils.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

thx

[...]
Anton Khirnov Feb. 10, 2020, 12:07 p.m. UTC | #2
Commit message summaries like "fix bug [$whatever external identifier]
are evil and should not be accepted IMO. They provide zero useful
information to someone reading the mailing list subjects or git
shortlog.

The commit message summary should be understandable on its own, without
reading the whole commit message or looking up any external information.
In this case, 'fix a double free' would be appropriate.  Any external
identifiers should be moved to the body of the message.
Gautam Ramakrishnan Feb. 10, 2020, 12:55 p.m. UTC | #3
On Mon, Feb 10, 2020 at 5:38 PM Anton Khirnov <anton@khirnov.net> wrote:
>
> Commit message summaries like "fix bug [$whatever external identifier]
> are evil and should not be accepted IMO. They provide zero useful
> information to someone reading the mailing list subjects or git
> shortlog.
>
> The commit message summary should be understandable on its own, without
> reading the whole commit message or looking up any external information.
> In this case, 'fix a double free' would be appropriate.  Any external
> identifiers should be moved to the body of the message.
>
> --
> Anton Khirnov
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Shall keep in this mind next time. Did not think about it while
sending the patch.
diff mbox series

Patch

diff --git a/libswscale/utils.c b/libswscale/utils.c
index b2c08a5983..e9c66aeb4f 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1502,6 +1502,7 @@  av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
         ff_free_filters(c2);
         if (ff_init_filters(c2) < 0) {
             sws_freeContext(c2);
+            c->cascaded_context[1] = NULL;
             return -1;
         }