Skip to content
Myr

Initialise jq_state->input_cb{,_data} to NULL in jq_init()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

To avoid causing segmentation faults when input/1 is called in a jq_state on which jq_set_input_cb() has not been called; e.g. the one used by jq --run-tests. That segfault could also be fixed in run_jq_tests() by calling: jq_set_input_cb(jq, NULL, NULL); But I think it makes sense to just make jq_init() initialise those values to NULL.

authored by Emanuele Torre · committed by Nico Williams · parent 1cb9ba3 · Browse files · 2 files+10 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Ref: https://github.com/jqlang/jq/pull/2717#discussion_r1264338841

Diff stats

2 files+10 added−0 removed

  • tests:+7 added−0 removed
  • other:+3 added−0 removed

2 files+10 added−0 removed

modified:src/execute.c+3 added
1010 unmodified lines
1011 jq->halted = 0;1012 jq->exit_code = jv_invalid();1013 jq->error_message = jv_invalid();10141015 jq->input_cb = NULL;1016 jq->input_cb_data = NULL;10171018 jq->err_cb = default_err_cb;1019 jq->err_cb_data = stderr;10201021 jq->attrs = jv_object();
251 unmodified lines
modified:tests/jq.test+7 added
1816 unmodified lines
18171818tojson | fromjson1819{"a":nan}1820{"a":null}182118221823# calling input/1 in a test doesn't crash jq18241825try input catch .1826null1827"break"