From 7656de906a43663b63febd8f8dbf70562a41f52391f97912f666c928c48f5d54 Mon Sep 17 00:00:00 2001 From: Stefan Dirsch Date: Tue, 22 Feb 2022 20:39:31 +0000 Subject: [PATCH] Accepting request 956857 from home:iznogood:branches:X11:XOrg - U_Fix-build-with-gcc-12.patch * render: Fix build with gcc 12 (glfdo#xorg/xserver!853). https://gitlab.freedesktop.org/xorg/xserver/-/commit/c6b0dcb82d4db07a2f32c09a8c09c85a5f57248e OBS-URL: https://build.opensuse.org/request/show/956857 OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/xorg-x11-server?expand=0&rev=819 --- U_Fix-build-with-gcc-12.patch | 89 +++++++++++++++++++++++++++++++++++ xorg-x11-server.changes | 6 +++ xorg-x11-server.spec | 3 ++ 3 files changed, 98 insertions(+) create mode 100644 U_Fix-build-with-gcc-12.patch diff --git a/U_Fix-build-with-gcc-12.patch b/U_Fix-build-with-gcc-12.patch new file mode 100644 index 0000000..54af600 --- /dev/null +++ b/U_Fix-build-with-gcc-12.patch @@ -0,0 +1,89 @@ +From c6b0dcb82d4db07a2f32c09a8c09c85a5f57248e Mon Sep 17 00:00:00 2001 +From: Olivier Fourdan +Date: Thu, 20 Jan 2022 10:20:38 +0100 +Subject: [PATCH] render: Fix build with gcc 12 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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 +Acked-by: Michel Dänzer +Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1256 +--- + render/picture.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/render/picture.c b/render/picture.c +index afa0d258f..2be4b1954 100644 +--- a/render/picture.c ++++ b/render/picture.c +@@ -865,7 +865,7 @@ CreateSolidPicture(Picture pid, xRenderColor * color, int *error) + } + + pPicture->id = pid; +- pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictSolidFill)); ++ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(SourcePict)); + if (!pPicture->pSourcePict) { + *error = BadAlloc; + free(pPicture); +@@ -896,7 +896,7 @@ CreateLinearGradientPicture(Picture pid, xPointFixed * p1, xPointFixed * p2, + } + + pPicture->id = pid; +- pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictLinearGradient)); ++ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(SourcePict)); + if (!pPicture->pSourcePict) { + *error = BadAlloc; + free(pPicture); +@@ -936,7 +936,7 @@ CreateRadialGradientPicture(Picture pid, xPointFixed * inner, + } + + pPicture->id = pid; +- pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictRadialGradient)); ++ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(SourcePict)); + if (!pPicture->pSourcePict) { + *error = BadAlloc; + free(pPicture); +@@ -979,7 +979,7 @@ CreateConicalGradientPicture(Picture pid, xPointFixed * center, xFixed angle, + } + + pPicture->id = pid; +- pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(PictConicalGradient)); ++ pPicture->pSourcePict = (SourcePictPtr) malloc(sizeof(SourcePict)); + if (!pPicture->pSourcePict) { + *error = BadAlloc; + free(pPicture); +-- +GitLab + diff --git a/xorg-x11-server.changes b/xorg-x11-server.changes index 66d5324..fec81bc 100644 --- a/xorg-x11-server.changes +++ b/xorg-x11-server.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Feb 22 18:24:20 UTC 2022 - Bjørn Lie + +- U_Fix-build-with-gcc-12.patch + * render: Fix build with gcc 12 (glfdo#xorg/xserver!853). + ------------------------------------------------------------------- Sat Feb 12 11:12:33 UTC 2022 - Stefan Dirsch diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index c337e73..f7ec324 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -244,6 +244,8 @@ Patch1930: u_xfree86-activate-GPU-screens-on-autobind.patch Patch1940: U_xephyr-Don-t-check-for-SeatId-anymore.patch +Patch1950: U_Fix-build-with-gcc-12.patch + %description This package contains the X.Org Server. @@ -399,6 +401,7 @@ sh %{SOURCE92} --verify . %{SOURCE91} %patch1920 -p1 %patch1930 -p1 %patch1940 -p1 +%patch1950 -p1 %build %global _lto_cflags %{?_lto_cflags} -ffat-lto-objects