summary refs log tree commit diff stats
path: root/plugins/python
diff options
context:
space:
mode:
authorTingPing <tngpng@gmail.com>2013-03-12 07:37:40 -0300
committerTingPing <tngpng@gmail.com>2013-03-12 07:37:40 -0300
commitd1e2048239c38ca43956ae71c271ba5c68b8ac6b (patch)
treea2d96b17337ff6798b5c431084c5bbbafab7fbaf /plugins/python
parentb5f78f484d43c73976085fe59e5995ba4c6c242f (diff)
fix python's get_pluginpref crashing on long strings
Diffstat (limited to 'plugins/python')
-rw-r--r--plugins/python/python.c11
1 files 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;