diff options
author | Patrick Griffis <tingping@tingping.se> | 2016-08-05 20:55:11 -0400 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2016-08-05 20:56:16 -0400 |
commit | 034624983b4ece4d8d1f7b604e6f8ce9007c627d (patch) | |
tree | 08aee84c71e57d71513436aa70fa39613e5f4e48 | |
parent | 74f014bd8cc1c68c321c0717e4ae833feda82584 (diff) |
plugin: Fix return value of hexchat_pluginpref_get_int()
On failure it should always return -1, atoi() returns 0. Fixes #1785
-rw-r--r-- | src/common/plugin.c | 8 |
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 { |