Re: [Patch] Fix cairo segfault when playing shogi
Adrian Petrescu <[email protected]> Mon, 5 Feb 2018 07:34:10 -0500
| Newsgroups | gmane.comp.gnu.xboard.devel |
|---|---|
| Message-ID | <CAFaB7Ra9De_agjBWfLhaHDp6q0e_2cXE=QKSeE2kHZYQdtKOzw@mail.gmail.com> |
--089e0832c2606fb828056476476b Content-Type: text/plain; charset="UTF-8" Thank you! This fixes the crash I reported back in December :) On Sun, Feb 4, 2018 at 3:24 PM, Justin Vreeland <[email protected]> wrote: > There's an off-by-one error caused when selecting square colors for held > pieces > that frequently causes pngBoardBitmap to access a value past it's bounds, > which > also is likely to include an invalid status field. > > The code in cairo and xboard seem to handle nulls well, this patch > simply expands that array without initializing the final instance. > --- > draw.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/draw.c b/draw.c > index 8b788925..f4aa94d2 100644 > --- a/draw.c > +++ b/draw.c > @@ -110,7 +110,7 @@ static cairo_surface_t *pngPieceImages[2][(int)BlackPawn]; > // png 256 x 256 im > static cairo_surface_t *pngPieceBitmaps[2][(int)BlackPawn]; // scaled > pieces as used > static cairo_surface_t *pngPieceBitmaps2[2][(int)BlackPawn]; // scaled > pieces in store > static RsvgHandle *svgPieces[2][(int)BlackPawn]; // vector pieces in store > -static cairo_surface_t *pngBoardBitmap[2], *pngOriginalBoardBitmap[2]; > +static cairo_surface_t *pngBoardBitmap[3], *pngOriginalBoardBitmap[2]; > int useTexture, textureW[2], textureH[2]; > > #define pieceToSolid(piece) &pieceBitmap[SOLID][(piece) % (int)BlackPawn] > -- > 2.16.1 > > > --089e0832c2606fb828056476476b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Thank you! This fixes the crash I reported back in Decembe= r :)<br></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On = Sun, Feb 4, 2018 at 3:24 PM, Justin Vreeland <span dir=3D"ltr"><<a href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>= ></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0= 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There's an off-by-= one error caused when selecting square colors for held pieces<br> that frequently causes pngBoardBitmap to access a value past it's bound= s, which<br> also is likely to include an invalid status field.<br> <br> The code in cairo and xboard seem to handle nulls well, this patch<br> simply expands that array without initializing the final instance.<br> ---<br> =C2=A0draw.c | 2 +-<br> =C2=A01 file changed, 1 insertion(+), 1 deletion(-)<br> <br> diff --git a/draw.c b/draw.c<br> index 8b788925..f4aa94d2 100644<br> --- a/draw.c<br> +++ b/draw.c<br> @@ -110,7 +110,7 @@ static cairo_surface_t *pngPieceImages[2][(int)<wbr>Bla= ckPawn];=C2=A0 =C2=A0// png 256 x 256 im<br> =C2=A0static cairo_surface_t *pngPieceBitmaps[2][(int)<wbr>BlackPawn];=C2= =A0 // scaled pieces as used<br> =C2=A0static cairo_surface_t *pngPieceBitmaps2[2][(int)<wbr>BlackPawn]; // = scaled pieces in store<br> =C2=A0static RsvgHandle *svgPieces[2][(int)BlackPawn]; // vector pieces in = store<br> -static cairo_surface_t *pngBoardBitmap[2], *pngOriginalBoardBitmap[2];<br> +static cairo_surface_t *pngBoardBitmap[3], *pngOriginalBoardBitmap[2];<br> =C2=A0int useTexture, textureW[2], textureH[2];<br> <br> =C2=A0#define pieceToSolid(piece) &pieceBitmap[SOLID][(piece) % (int)Bl= ackPawn]<br> <span class=3D"HOEnZb"><font color=3D"#888888">--<br> 2.16.1<br> <br> <br> </font></span></blockquote></div><br></div> --089e0832c2606fb828056476476b--