Skip to content

Commit

Permalink
walk: Don't crash when assertion is compiled out in release mode
Browse files Browse the repository at this point in the history
There's a bunch of asserts here (signifying this is experimental code).
When compiled in release mode the asserts are removed and then the
subsequence code crashes with a SEGV.

Make it just to error out.

Fixes #123

Signed-off-by: Pantelis Antoniou <[email protected]>
  • Loading branch information
pantoniou committed Sep 30, 2024
1 parent 659f1a9 commit fa02ddf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/fy-walk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5006,6 +5006,8 @@ fy_path_expr_execute(struct fy_path_exec *fypx, int level, struct fy_path_expr *

/* pop the top in either case */
assert(input);
if (!input)
goto out;

/* only handle inputs of node and refs */
if (input->type != fwrt_node_ref && input->type != fwrt_refs) {
Expand All @@ -5017,9 +5019,13 @@ fy_path_expr_execute(struct fy_path_exec *fypx, int level, struct fy_path_expr *
/* execute the expression */
exprn = fy_path_expr_list_head(&expr->children);
assert(exprn);
if (!exprn)
goto out;

fwrt = fy_walk_result_clone(input);
assert(fwrt);
if (!fwrt)
goto out;

fwrn = fy_path_expr_execute(fypx, level + 1, exprn, fwrt, expr->type);

Expand Down

0 comments on commit fa02ddf

Please sign in to comment.