File 0001-xcb-guard-a-pointer-before-usage.patch of Package libqt5-qtbase.32007

From df77d8939d1c04aa18833fe1e141bb71af1f8e04 Mon Sep 17 00:00:00 2001
From: Liang Qi <liang.qi@qt.io>
Date: Mon, 31 Jul 2023 05:35:11 +0200
Subject: [PATCH] xcb: guard a pointer before usage

in QXcbAtom::initializeAllAtoms().

See also the example in
https://manpages.debian.org/testing/libxcb-doc/xcb_intern_atom_reply.3.en.html

Fixes: QTBUG-115599
Change-Id: I6590fe1aa11deec7fef7ce6d8f5c49a71d636648
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 552e3b9b78c136aebedf0a591af04661f0dedbbf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
---
 src/plugins/platforms/xcb/qxcbatom.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/plugins/platforms/xcb/qxcbatom.cpp b/src/plugins/platforms/xcb/qxcbatom.cpp
index 6cb6d29de247..ccebd16ee0d7 100644
--- a/src/plugins/platforms/xcb/qxcbatom.cpp
+++ b/src/plugins/platforms/xcb/qxcbatom.cpp
@@ -236,8 +236,10 @@ void QXcbAtom::initializeAllAtoms(xcb_connection_t *connection) {
 
     for (i = 0; i < QXcbAtom::NAtoms; ++i) {
         xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], nullptr);
-        m_allAtoms[i] = reply->atom;
-        free(reply);
+        if (reply) {
+            m_allAtoms[i] = reply->atom;
+            free(reply);
+        }
     }
 }
 
-- 
2.16.3

openSUSE Build Service is sponsored by