From cbb8ef9f3f4442906c9303efaefec041c1ee9688 Mon Sep 17 00:00:00 2001 From: pawelz Date: Fri, 22 Jan 2010 00:41:28 +0000 Subject: [PATCH] - fix segfault in ekg2 on x86_64 Changed files: ekg2-python-x8664-segfault.patch -> 1.1 --- ekg2-python-x8664-segfault.patch | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 ekg2-python-x8664-segfault.patch diff --git a/ekg2-python-x8664-segfault.patch b/ekg2-python-x8664-segfault.patch new file mode 100644 index 0000000..5a64963 --- /dev/null +++ b/ekg2-python-x8664-segfault.patch @@ -0,0 +1,38 @@ +git://github.com/pawelz/ekg2.git branch master: + +commit a31760d809e3e464e5e26dc42de97a5e1c9ec53f +Author: Paweł Zuzelski +Date: Fri Jan 22 01:17:47 2010 +0100 + + fixed conversion from long to PyObject + + The false assumption sizeof(long) == size(void*) exists where PyInt_FromLong + is used to represent a pointer. The safe Python call for this is + PyLong_FromVoidPtr. (On platforms where the above assumption *is* true a PyInt + is returned as before so there is no effective change.) + + This fixes segfault on x86_64 machines. The simplest way to reproduce segfault + is to load the following python script: + + import ekg + + def reply(session, uid, type, text, stime, ignore_level): + ekg.command("/msg "+uid+" "+text) + + ekg.handler_bind('protocol-message', reply) + + and receive any message. + +diff --git a/plugins/python/python.c b/plugins/python/python.c +index 272ad4f..9a33049 100644 +--- a/plugins/python/python.c ++++ b/plugins/python/python.c +@@ -222,7 +222,7 @@ int python_query(script_t *scr, script_query_t *scr_que, void **args) + PyObject *w = NULL; + switch ( scr_que->argv_type[i] ) { + case (QUERY_ARG_INT): +- w = PyInt_FromLong((long) *(int *) args[i] ); ++ w = PyLong_FromVoidPtr( args[i] ); + break; + case (QUERY_ARG_CHARP): { + char *tmp = *(char **) args[i]; -- 2.44.0