1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 02:03:13 +02:00

core: fix evaluation of condition when the left operand is an empty string

This commit is contained in:
Sébastien Helleu
2018-08-18 15:30:16 +02:00
parent 97ad48e317
commit 6bf0dfddd6
3 changed files with 21 additions and 5 deletions
+12 -5
View File
@@ -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]);