Skip to content

Commit

Permalink
Segfault (is)/2, re issue #601
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Oct 2, 2024
1 parent a38ca66 commit ff6e29c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/bif_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ bool call_builtin(query *q, cell *c, pl_idx c_ctx)
#endif
if (!c->bif_ptr->evaluable && (c->val_off != g_float_s))
return throw_error(q, &q->accum, q->st.curr_frame, "type_error", "evaluable");
else if (q->max_eval_depth++ > g_max_depth)
return throw_error(q, q->st.curr_instr, q->st.curr_frame, "type_error", "evaluable");
else
c->bif_ptr->fn(q);

Expand All @@ -297,6 +299,7 @@ static bool bif_iso_is_2(query *q)
{
GET_FIRST_ARG(p1,any);
GET_NEXT_ARG(p2_tmp,any);
q->max_eval_depth = 0;

CLEANUP cell p2 = eval(q, p2_tmp);
p2.nbr_cells = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ struct query_ {
uint64_t tot_tcos, step, qid, tmo_msecs, chgen, cycle_error;
uint64_t get_started, autofail_n, yield_at;
uint64_t cpu_started, time_cpu_last_started, future;
unsigned max_depth, print_idx, tab_idx, dump_var_nbr;
unsigned max_depth, max_eval_depth, print_idx, tab_idx, dump_var_nbr;
unsigned varno, tab0_varno, curr_engine, curr_chan, my_chan, oom;
unsigned s_cnt;
pl_idx tmphp, latest_ctx, popp, variable_names_ctx;
Expand Down

0 comments on commit ff6e29c

Please sign in to comment.