summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-11-07 20:16:26 +0100
committerSébastien Helleu <flashcode@flashtux.org>2021-11-07 20:16:26 +0100
commit253b25db035c92e0e86e7a5dac3559ff144469f7 (patch)
tree4f304f47c6c6b2280acbd57839c7e8f00d13b8e3 /src/core
parent4c9e7ed09e8a09143d61e9d18de877adeadd65c3 (diff)
downloadweechat-253b25db035c92e0e86e7a5dac3559ff144469f7.zip
core: fix random integer number with large range in evaluation of expressions on GNU/Hurd
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-eval.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 6c1fd22ec..10d943010 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -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: