Fix Py_XDECREF of an unitialized pointer

- Resolves: RHEL-120796
This commit is contained in:
Charalampos Stratakis 2026-01-13 02:13:15 +01:00
parent a3a38eb846
commit 7cc1eea408
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,24 @@
From ee1a87bc489f14681dacd3fdc518dd40bbab81ea Mon Sep 17 00:00:00 2001
From: Charalampos Stratakis <cstratak@redhat.com>
Date: Fri, 12 Dec 2025 19:54:48 +0100
Subject: [PATCH] Initialize interned_fields to NULL
This avoids a code path where Py_XDECREF could be used on
interned_fields when uninitialized.
---
src/c/_cffi_backend.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/c/_cffi_backend.c b/src/c/_cffi_backend.c
index 835e3318..6087e635 100644
--- a/src/c/_cffi_backend.c
+++ b/src/c/_cffi_backend.c
@@ -5152,7 +5152,7 @@ static PyObject *b_complete_struct_or_union_lock_held(CTypeDescrObject *ct,
Py_ssize_t byteoffsetorg;
CFieldObject **previous;
int prev_bitfield_size, prev_bitfield_free;
- PyObject *interned_fields;
+ PyObject *interned_fields = NULL;
sflags = complete_sflags(sflags);
if (sflags & SF_PACKED)

View File

@ -10,6 +10,11 @@ License: MIT AND PSF-2.0
URL: https://github.com/python-cffi/cffi
Source: %{url}/archive/v%{version}/cffi-%{version}.tar.gz
# Fix coverity scan issue
# Possibility of using Py_XDECREF on an uninitialized pointer
# Resolved upstream: https://github.com/python-cffi/cffi/pull/221
Patch: fix-pyxdecref-uninit-pointer.patch
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: make