xserver/render
Olivier Fourdan c6b0dcb82d render: Fix build with gcc 12
The xserver fails to compile with the latest gcc 12:

 render/picture.c: In function ‘CreateSolidPicture’:
 render/picture.c:874:26: error: array subscript ‘union _SourcePict[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
  874 |     pPicture->pSourcePict->type = SourcePictTypeSolidFill;
      |                          ^~
 render/picture.c:868:45: note: object of size 16 allocated by ‘malloc’
  868 |     pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictSolidFill));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 render/picture.c: In function ‘CreateLinearGradientPicture’:
 render/picture.c:906:26: error: array subscript ‘union _SourcePict[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Werror=array-bounds]
  906 |     pPicture->pSourcePict->linear.type = SourcePictTypeLinear;
      |                          ^~
 render/picture.c:899:45: note: object of size 32 allocated by ‘malloc’
  899 |     pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictLinearGradient));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 render/picture.c: In function ‘CreateConicalGradientPicture’:
 render/picture.c:989:26: error: array subscript ‘union _SourcePict[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Werror=array-bounds]
  989 |     pPicture->pSourcePict->conical.type = SourcePictTypeConical;
      |                          ^~
 render/picture.c:982:45: note: object of size 32 allocated by ‘malloc’
  982 |     pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictConicalGradient));
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 cc1: some warnings being treated as errors
 ninja: build stopped: subcommand failed.

This is because gcc 12 has become stricter and raises a warning now.

Fix the warning/error by allocating enough memory to store the union
struct.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1256
2022-01-25 16:16:30 +01:00
..
animcur.c animcur: Fix crash when removing a master device 2018-04-24 14:28:27 -04:00
filter.c Convert top level extensions to new *allocarray functions 2015-04-21 16:57:08 -07:00
glyph.c Use ARRAY_SIZE all over the tree 2017-10-30 13:45:20 -04:00
glyphstr.h render: Hide/unexport some implementation details 2015-07-08 16:40:57 -04:00
matrix.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
meson.build meson: hide C API if Xorg is disabled (like autotools) 2021-03-11 00:22:36 +00:00
miindex.c Convert top level extensions to new *allocarray functions 2015-04-21 16:57:08 -07:00
mipict.c mi: Add a default no-op miSourceValidate 2019-10-30 16:26:01 +00:00
mipict.h render: Hide/unexport some implementation details 2015-07-08 16:40:57 -04:00
mirect.c render: Simplify miCompositeRects 2018-02-26 10:02:24 -05:00
mitrap.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
mitri.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
picture.c render: Fix build with gcc 12 2022-01-25 16:16:30 +01:00
picture.h exa: only draw valid trapezoids 2016-06-17 11:21:30 +02:00
picturestr.h render: Store and use all 16bpc of precision for solid pixels (v2.1) 2018-02-26 16:46:34 -05:00
render.c render: Fix out of bounds access in SProcRenderCompositeGlyphs() 2021-12-14 15:00:03 +02:00