]> git.alsa-project.org Git - alsa-python.git/commitdiff
alsaseq: fix seg. fault when accessing `ConstantObject` extra
authorFrancesco Ceruti <ceppofrancy@gmail.com>
Sat, 4 May 2024 20:16:16 +0000 (22:16 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 31 May 2024 09:17:53 +0000 (11:17 +0200)
Closes: https://github.com/alsa-project/alsa-python/pull/10
Signed-off-by: Francesco Ceruti <ceppofrancy@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
pyalsa/alsaseq.c

index b2959fbf0e0606f44382016b693629ac5ad36a12..98a503098601b99927e6db85dfd9098da54713c2 100644 (file)
@@ -353,18 +353,11 @@ typedef struct {
 } ConstantObject;
 
 #if PY_MAJOR_VERSION < 3
-/* PyInt is fixed size in Python 2 */
 # define CONST_VALUE(x) PyInt_AsLong((PyObject *)x)
-# define CONST_EXTRA(x) (&(x->extra))
 #else
-/* PyLong is variable size in Python 3 */
 # define CONST_VALUE(x) PyLong_AsLong((PyObject *)x)
-# define CONST_EXTRA(x) \
-    ((ConstantExtraFields *)( \
-        ((intptr_t)(&x->extra)) \
-        + abs(Py_SIZE(&x->base)) * Py_TYPE(x)->tp_itemsize \
-    ))
 #endif
+# define CONST_EXTRA(x) (&(x->extra))
 
 /** alsaseq.Constant type (initialized later...) */
 static PyTypeObject ConstantType;