1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 14:56:39 +02:00

core: fix random integer number with large range in evaluation of expressions on GNU/Hurd

This commit is contained in:
Sébastien Helleu
2021-11-07 20:16:26 +01:00
parent 4c9e7ed09e
commit 253b25db03
2 changed files with 5 additions and 4 deletions
+1
View File
@@ -29,6 +29,7 @@ New features::
Bug fixes::
* core: fix random integer number with large range in evaluation of expressions on GNU/Hurd
* core: fix access to integer/long/time arrays in hdata
* api: fix search of option when the section is not given in functions config_search_option and config_search_section_option
* irc: fix join of channels with long name (issue #1717)
+4 -4
View File
@@ -1008,7 +1008,7 @@ char *
eval_string_random (const char *text)
{
char *pos, *error, *tmp, result[128];
long min_number, max_number;
long long min_number, max_number;
if (!text || !text[0])
goto error;
@@ -1020,7 +1020,7 @@ eval_string_random (const char *text)
tmp = strndup (text, pos - text);
if (!tmp)
goto error;
min_number = strtol (tmp, &error, 10);
min_number = strtoll (tmp, &error, 10);
if (!error || error[0])
{
free (tmp);
@@ -1028,7 +1028,7 @@ eval_string_random (const char *text)
}
free (tmp);
max_number = strtol (pos + 1, &error, 10);
max_number = strtoll (pos + 1, &error, 10);
if (!error || error[0])
goto error;
@@ -1042,7 +1042,7 @@ eval_string_random (const char *text)
* but this is enough for our usage here
*/
snprintf (result, sizeof (result),
"%ld", min_number + (random () % (max_number - min_number + 1)));
"%lld", min_number + (random () % (max_number - min_number + 1)));
return strdup (result);
error: