[lunatic-python] Segfault patch.

Jon Ciesla limb at fedoraproject.org
Mon Jul 25 12:56:00 UTC 2011


commit 767139d315e41b2c8dc5c88294f9c84ae0b029a4
Author: Jon Ciesla <limb at jcomserv.net>
Date:   Mon Jul 25 07:49:58 2011 -0500

    Segfault patch.

 lunatic-python-lua-py-segfault.patch |   34 ++++++++++++++++++++++++++++++++++
 lunatic-python.spec                  |    7 ++++++-
 2 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/lunatic-python-lua-py-segfault.patch b/lunatic-python-lua-py-segfault.patch
new file mode 100644
index 0000000..4fca0ae
--- /dev/null
+++ b/lunatic-python-lua-py-segfault.patch
@@ -0,0 +1,34 @@
+--- src/pythoninlua.c~	2009-09-17 21:45:43.000000000 -0500
++++ src/pythoninlua.c	2011-07-25 07:52:38.000000000 -0500
+@@ -28,6 +28,13 @@
+ #include "pythoninlua.h"
+ #include "luainpython.h"
+ 
++/* Py_ssize_t introduced as index type in Python 2.5 (PEP 353) */
++#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
++typedef int Py_ssize_t;
++#define PY_SSIZE_T_MAX INT_MAX
++#define PY_SSIZE_T_MIN INT_MIN
++#endif
++
+ static int py_asfunc_call(lua_State *L);
+ 
+ static int py_convert_custom(lua_State *L, PyObject *o, int asindx)
+@@ -70,7 +77,7 @@
+ 		lua_pushboolean(L, 0);
+ 	} else if (PyString_Check(o)) {
+ 		char *s;
+-		int len;
++		Py_ssize_t len;
+ 		PyString_AsStringAndSize(o, &s, &len);
+ 		lua_pushlstring(L, s, len);
+ 		ret = 1;
+@@ -331,7 +338,7 @@
+ 			PyErr_Clear();
+ 		} else {
+ 			char *s;
+-			int len;
++			Py_ssize_t len;
+ 			PyString_AsStringAndSize(repr, &s, &len);
+ 			lua_pushlstring(L, s, len);
+ 			Py_DECREF(repr);
diff --git a/lunatic-python.spec b/lunatic-python.spec
index a0d2509..4061490 100644
--- a/lunatic-python.spec
+++ b/lunatic-python.spec
@@ -6,7 +6,7 @@
 
 Name:           lunatic-python
 Version:        1.0.1
-Release:        0.4.%{bzrdate}bzr%{?dist}
+Release:        0.5.%{bzrdate}bzr%{?dist}
 Summary:        Two-way bridge between Python and Lua
 
 Group:          Development/Languages
@@ -16,6 +16,7 @@ URL:            http://labix.org/lunatic-python
 # (cd lunatic-python && \
 #  bzr export --root=lunatic-python ../lunatic-python.tar.bz2)
 Source0:        %{name}.tar.bz2
+Patch0:		lunatic-python-lua-py-segfault.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  python-devel lua-devel
@@ -30,6 +31,7 @@ Lua, Python inside Lua inside Python, and so on.
 %prep
 %setup -q -n %{name}
 
+%patch0 -p0
 
 %build
 CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
@@ -55,6 +57,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Mon Jul 25 2011 Jon Ciesla <limb at jcomserv.net> - 1.0.1-0.5.20090917bzr
+- Patch for segfault, BZ 692287.
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.0.1-0.4.20090917bzr
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list