summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-08-18 15:30:16 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-08-18 15:30:16 +0200
commit6bf0dfddd6685d9f37f4c03db7b64cb8e5966000 (patch)
tree59ff2127366bfbe79c36f3c4e85adb9c4267984c /src/core
parent97ad48e317782c5fa3e176c43e4120b5dde1ebe5 (diff)
downloadweechat-6bf0dfddd6685d9f37f4c03db7b64cb8e5966000.zip
core: fix evaluation of condition when the left operand is an empty string
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-eval.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index fffc07fb0..111277735 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -962,14 +962,21 @@ eval_expression_condition (const char *expr,
for (comp = 0; comp < EVAL_NUM_COMPARISONS; comp++)
{
pos = eval_strstr_level (expr2, comparisons[comp], "(", ")", 0);
- if (pos > expr2)
+ if (pos >= expr2)
{
- pos_end = pos - 1;
- while ((pos_end > expr2) && (pos_end[0] == ' '))
+ if (pos > expr2)
{
- pos_end--;
+ pos_end = pos - 1;
+ while ((pos_end > expr2) && (pos_end[0] == ' '))
+ {
+ pos_end--;
+ }
+ sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
+ }
+ else
+ {
+ sub_expr = strdup ("");
}
- sub_expr = string_strndup (expr2, pos_end + 1 - expr2);
if (!sub_expr)
goto end;
pos += strlen (comparisons[comp]);