plugin: Fix return value of hexchat_pluginpref_get_int()

On failure it should always return -1, atoi() returns 0.

Fixes #1785
This commit is contained in:
Patrick Griffis 2016-08-05 20:55:11 -04:00
parent 74f014bd8c
commit 034624983b
1 changed files with 7 additions and 1 deletions

View File

@ -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
{