From 034624983b4ece4d8d1f7b604e6f8ce9007c627d Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Fri, 5 Aug 2016 20:55:11 -0400 Subject: plugin: Fix return value of hexchat_pluginpref_get_int() On failure it should always return -1, atoi() returns 0. Fixes #1785 --- src/common/plugin.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 { -- cgit 1.4.1