Skip to content

Commit

Permalink
Detect empty filtering expressions, do not segfault. Fixes #2341
Browse files Browse the repository at this point in the history
  • Loading branch information
pd3 committed Dec 17, 2024
1 parent 00dc466 commit 1535cc2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,6 @@ static int filters_next_token(char **str, int *len)
return TOK_VAL;
}

#define FILTER_OK 0
#define FILTER_ERR_UNKN_TAGS 1
#define FILTER_ERR_OTHER 2

static void filter_add_undef_tag(filter_t *filter, char *str)
{
int i;
Expand Down Expand Up @@ -3688,6 +3684,12 @@ static filter_t *filter_init_(bcf_hdr_t *hdr, const char *str, int exit_on_error
nops--;
}

if ( !nout )
{
if ( filter->exit_on_error )
error("[%s:%d %s] Error: could not parse the expression \"%s\"\n", __FILE__,__LINE__,__FUNCTION__,filter->str);
filter->status |= FILTER_ERR_OTHER;
}
if ( filter->status != FILTER_OK )
{
if ( mops ) free(ops);
Expand Down

0 comments on commit 1535cc2

Please sign in to comment.