xorg-x11-server-Xwayland/0007-panoramix-avoid-null-dereference-in-PanoramiXConsoli.patch
2026-06-16 09:59:01 +02:00

72 lines
3.2 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From ccd2a541458a844397757cebade4970173471a30 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat, 20 Sep 2025 16:45:59 -0700
Subject: [PATCH xserver 07/31] panoramix: avoid null dereference in
PanoramiXConsolidate()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reported in #1817:
Error: GCC_ANALYZER_WARNING (CWE-476): [#def5]
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:820:5: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘root’
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:819:12: acquire_memory: this call could return NULL
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:820:5: danger: ‘root’ could be NULL: unchecked value from (1)
818|
819| root = malloc(sizeof(PanoramiXRes));
820|-> root->type = XRT_WINDOW;
821| defmap = malloc(sizeof(PanoramiXRes));
822| defmap->type = XRT_COLORMAP;
Error: GCC_ANALYZER_WARNING (CWE-476): [#def6]
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:822:5: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘defmap’
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:821:14: acquire_memory: this call could return NULL
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:822:5: danger: ‘defmap’ could be NULL: unchecked value from (1)
820| root->type = XRT_WINDOW;
821| defmap = malloc(sizeof(PanoramiXRes));
822|-> defmap->type = XRT_COLORMAP;
823| saver = malloc(sizeof(PanoramiXRes));
824| saver->type = XRT_WINDOW;
Error: GCC_ANALYZER_WARNING (CWE-476): [#def7]
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:824:5: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘saver’
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:823:13: acquire_memory: this call could return NULL
xwayland-24.1.6/redhat-linux-build/../Xext/panoramiX.c:824:5: danger: ‘saver’ could be NULL: unchecked value from (1)
822| defmap->type = XRT_COLORMAP;
823| saver = malloc(sizeof(PanoramiXRes));
824|-> saver->type = XRT_WINDOW;
825|
826| FOR_NSCREENS(i) {
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 23c103d41f35cc030b0c0e973f7f3bcb8d9902a0)
(cherry picked from commit 6edd79e5f50df456c7dccc693188229684d8f55f)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2151>
---
Xext/panoramiX.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index c6d0e5183..cea919bf0 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -816,11 +816,11 @@ PanoramiXConsolidate(void)
for (i = 0; i < pScreen->numVisuals; i++)
PanoramiXMaybeAddVisual(pVisual++);
- root = malloc(sizeof(PanoramiXRes));
+ root = XNFcallocarray(1, sizeof(PanoramiXRes));
root->type = XRT_WINDOW;
- defmap = malloc(sizeof(PanoramiXRes));
+ defmap = XNFcallocarray(1, sizeof(PanoramiXRes));
defmap->type = XRT_COLORMAP;
- saver = malloc(sizeof(PanoramiXRes));
+ saver = XNFcallocarray(1, sizeof(PanoramiXRes));
saver->type = XRT_WINDOW;
FOR_NSCREENS(i) {
--
2.54.0