[FFmpeg-devel] [PATCH] Fix potential crash in swscale.c:pal2rgbWrapper()
Stefano Sabatini
stefano.sabatini-lala
Mon Jan 18 00:05:08 CET 2010
On date Sunday 2010-01-17 19:50:51 +0100, Michael Niedermayer encoded:
> On Sun, Jan 17, 2010 at 03:11:30PM +0100, Stefano Sabatini wrote:
> > Hi, as in subject.
> >
> > If pal2rgbWrapper is fed with a non-paletted format it currently
> > prints an error and then select a converter anyway, which will then be
> > used to scale non-paletted formats.
> >
> > Sane behavior seems to simply warn the user and don't do nothing.
>
>
>
> >
> > Bonus patch factorize the log message printing in case of error.
> >
> > Regards.
> > --
> > FFmpeg = Fiendish and Furious Murdering Power Ecumenical God
>
> > swscale.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> > 8d6b68a5d7e82f86c7bab285689f3dd1a21d4a2b fix-pal2rgb-wrapper.patch
>
> probably ok, dont forget testing!
>
>
> > Index: ffmpeg/libswscale/swscale.c
> > ===================================================================
> > --- ffmpeg.orig/libswscale/swscale.c 2010-01-17 13:45:48.000000000 +0100
> > +++ ffmpeg/libswscale/swscale.c 2010-01-17 13:47:18.000000000 +0100
> > @@ -2035,7 +2035,7 @@
> > if (!usePal(srcFormat))
> > av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > sws_format_name(srcFormat), sws_format_name(dstFormat));
> > -
> > + else {
> > switch(dstFormat) {
> > case PIX_FMT_RGB32 : conv = palette8topacked32; break;
> > case PIX_FMT_BGR32 : conv = palette8topacked32; break;
> > @@ -2046,8 +2046,9 @@
> > default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
> > }
> > + }
> >
> > -
> > + if (conv)
> > for (i=0; i<srcSliceH; i++) {
> > conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
> > srcPtr+= srcStride[0];
>
> > swscale.c | 12 +++++-------
> > 1 file changed, 5 insertions(+), 7 deletions(-)
> > 1a5996aaa59b886aeff719e820736137711867d6 factorize-errlog-in-pal2rgb-wrapper.patch
> > Index: ffmpeg/libswscale/swscale.c
> > ===================================================================
> > --- ffmpeg.orig/libswscale/swscale.c 2010-01-17 13:49:11.000000000 +0100
> > +++ ffmpeg/libswscale/swscale.c 2010-01-17 13:50:38.000000000 +0100
> > @@ -2032,10 +2032,7 @@
> > uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
> > const uint8_t *srcPtr= src[0];
> >
> > - if (!usePal(srcFormat))
> > - av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > - sws_format_name(srcFormat), sws_format_name(dstFormat));
> > - else {
> > + if (usePal(srcFormat)) {
> > switch(dstFormat) {
> > case PIX_FMT_RGB32 : conv = palette8topacked32; break;
> > case PIX_FMT_BGR32 : conv = palette8topacked32; break;
> > @@ -2043,12 +2040,13 @@
> > case PIX_FMT_RGB32_1: conv = palette8topacked32; break;
> > case PIX_FMT_RGB24 : conv = palette8topacked24; break;
> > case PIX_FMT_BGR24 : conv = palette8topacked24; break;
> > - default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > - sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
> > }
> > }
> >
> > - if (conv)
> > + if (!conv)
> > + av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
> > + sws_format_name(srcFormat), sws_format_name(dstFormat));
> > + else
>
> {}
> also i assume conv is inited to NULL (didnt check)
> otherwise it should be ok if tested
Applied.
--
FFmpeg = Faboulous & Fostering MultiPurpose Extreme Generator
More information about the ffmpeg-devel
mailing list