Skip to content

Commit

Permalink
Add check for null pointers in yr_lex_parse_rules_bytes and yr_lex_pa…
Browse files Browse the repository at this point in the history
…rse_rules_string

Closes #2139
  • Loading branch information
plusvic committed Feb 27, 2025
1 parent 53642c3 commit 93d1de6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libyara/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3549,6 +3549,9 @@ int yr_lex_parse_rules_bytes(

compiler->errors = 0;

if (rules_data == NULL)
return 0;

if (yylex_init(&yyscanner) != 0)
{
compiler->errors = 1;
Expand Down Expand Up @@ -3581,6 +3584,9 @@ int yr_lex_parse_rules_string(

compiler->errors = 0;

if (rules_string == NULL)
return 0;

if (yylex_init(&yyscanner) != 0)
{
compiler->errors = 1;
Expand Down
6 changes: 6 additions & 0 deletions libyara/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,9 @@ int yr_lex_parse_rules_bytes(

compiler->errors = 0;

if (rules_data == NULL)
return 0;

if (yylex_init(&yyscanner) != 0)
{
compiler->errors = 1;
Expand Down Expand Up @@ -927,6 +930,9 @@ int yr_lex_parse_rules_string(

compiler->errors = 0;

if (rules_string == NULL)
return 0;

if (yylex_init(&yyscanner) != 0)
{
compiler->errors = 1;
Expand Down

0 comments on commit 93d1de6

Please sign in to comment.