mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Fix crash in LOADVN when stack grows
This `stack_push()` call in LOADVN invalidates `var`: jv* var = frame_local_var(jq, v, level); jv_free(stack_popn(jq)); ------>stack_push(jq, *var); *var = jv_null(); ^^^^^^ We have to re-compute `var`: jv* var = frame_local_var(jq, v, level); jv_free(stack_popn(jq)); stack_push(jq, *var); ------>var = frame_local_var(jq, v, level); *var = jv_null();
This commit is contained in:
@@ -561,7 +561,11 @@ jv jq_next(jq_state *jq) {
|
||||
printf(" (%d)\n", jv_get_refcnt(*var));
|
||||
}
|
||||
jv_free(stack_popn(jq));
|
||||
|
||||
// This `stack_push()` invalidates the `var` reference, so
|
||||
stack_push(jq, *var);
|
||||
// we have to re-resolve `var` before we can set it to null
|
||||
var = frame_local_var(jq, v, level);
|
||||
*var = jv_null();
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user