From d1e2048239c38ca43956ae71c271ba5c68b8ac6b Mon Sep 17 00:00:00 2001 From: TingPing Date: Tue, 12 Mar 2013 07:37:40 -0300 Subject: [PATCH] fix python's get_pluginpref crashing on long strings --- plugins/python/python.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/python/python.c b/plugins/python/python.c index 5f98c6c7..239703a8 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -1610,12 +1610,15 @@ Module_hexchat_pluginpref_get(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "s:get_pluginpref", &var)) return NULL; // This will always return numbers as integers. - retint = hexchat_pluginpref_get_int(ph, var); if (hexchat_pluginpref_get_str(ph, var, retstr)) { - if ((retint == 0) && (strcmp(retstr, "0") != 0)) + if (strlen (retstr) <= 12) { + retint = hexchat_pluginpref_get_int(ph, var); + if ((retint == 0) && (strcmp(retstr, "0") != 0)) + ret = PyString_FromString(retstr); + else + ret = PyInt_FromLong(retint); + } else ret = PyString_FromString(retstr); - else - ret = PyInt_FromLong(retint); } else ret = Py_None;