1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-25 18:52:22 -05:00

fix python's get_pluginpref crashing on long strings

This commit is contained in:
TingPing 2013-03-12 07:37:40 -03:00
parent b5f78f484d
commit d1e2048239

View File

@ -1610,12 +1610,15 @@ Module_hexchat_pluginpref_get(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s:get_pluginpref", &var)) if (!PyArg_ParseTuple(args, "s:get_pluginpref", &var))
return NULL; return NULL;
// This will always return numbers as integers. // This will always return numbers as integers.
retint = hexchat_pluginpref_get_int(ph, var);
if (hexchat_pluginpref_get_str(ph, var, retstr)) { 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); ret = PyString_FromString(retstr);
else
ret = PyInt_FromLong(retint);
} }
else else
ret = Py_None; ret = Py_None;