]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
fix widget key collision in snack on 64-bit archs (#1151455)
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 23 Oct 2014 07:23:30 +0000 (09:23 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 23 Oct 2014 07:44:33 +0000 (09:44 +0200)
configure.ac
snack.c

index 92e6da85843d5262edab7454694b34f6ebd33031..2cc75d195779cb10e17234bf7345e7e98ccce043 100644 (file)
@@ -16,6 +16,10 @@ AC_PROG_LN_S
 AC_PROG_GREP
 AC_SYS_LARGEFILE
 
+AC_CHECK_SIZEOF([long])
+AC_CHECK_SIZEOF([long long])
+AC_CHECK_SIZEOF([void *])
+
 # Are we using GNU ld?
 AC_MSG_CHECKING([for GNU ld])
 LD=`$CC -print-prog-name=ld 2>&5`
diff --git a/snack.c b/snack.c
index b4cee2ecb44d7b8d4f04cf2c0d856a2ccc38d2c9..5ccdf74488ca62ee00b077ad8dd1d2559689fceb 100644 (file)
--- a/snack.c
+++ b/snack.c
@@ -317,7 +317,15 @@ static PyMethodDef widgetMethods[] = {
 };
 
 static PyMemberDef widget_members[] = {
-        { "key" , T_INT, offsetof(snackWidget, co), 0, NULL },
+        { "key",
+#if SIZEOF_VOID_P == SIZEOF_LONG
+               T_LONG,
+#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
+               T_LONGLONG,
+#else
+#error unsupported pointer size
+#endif
+               offsetof(snackWidget, co), 0, NULL },
         { "entryValue", T_STRING, offsetof(snackWidget, apointer), 0, NULL },
        { NULL }
 };
@@ -1020,7 +1028,11 @@ static PyObject * formRun(snackForm * s, PyObject * args) {
     else if (result.reason == NEWT_EXIT_FDREADY)
        return Py_BuildValue("(si)", "fdready", result.u.watch);
     else if (result.reason == NEWT_EXIT_COMPONENT)
-       return Py_BuildValue("(si)", "widget", result.u.co);
+#if SIZEOF_VOID_P <= SIZEOF_LONG
+       return Py_BuildValue("(sl)", "widget", (long)result.u.co);
+#else
+       return Py_BuildValue("(sL)", "widget", (long long)result.u.co);
+#endif
     else
        return Py_BuildValue("(si)", "error", 0);
 }