summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2016-08-05 20:55:11 -0400
committerPatrick Griffis <tingping@tingping.se>2016-08-05 20:56:16 -0400
commit034624983b4ece4d8d1f7b604e6f8ce9007c627d (patch)
tree08aee84c71e57d71513436aa70fa39613e5f4e48 /src
parent74f014bd8cc1c68c321c0717e4ae833feda82584 (diff)
plugin: Fix return value of hexchat_pluginpref_get_int()
On failure it should always return -1, atoi() returns 0.

Fixes #1785
Diffstat (limited to 'src')
-rw-r--r--src/common/plugin.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/common/plugin.c b/src/common/plugin.c
index 070b348b..4b45619d 100644
--- a/src/common/plugin.c
+++ b/src/common/plugin.c
@@ -1958,7 +1958,13 @@ hexchat_pluginpref_get_int (hexchat_plugin *pl, const char *var)
 
 	if (hexchat_pluginpref_get_str_real (pl, var, buffer, sizeof(buffer)))
 	{
-		return atoi (buffer);
+		int ret = atoi (buffer);
+
+		/* 0 could be success or failure, who knows */
+		if (ret == 0 && *buffer != '0')
+			return -1;
+
+		return ret;
 	}
 	else
 	{