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:
1 parent
07dc653ae1
commit
582717a7b4
1 file changed
+4
@@ -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