diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-24 15:31:11 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-24 15:33:18 +0200 |
commit | c43a54f6dc45590ce553a294ae59bd14324212f2 (patch) | |
tree | 42aac8229c6679983beada2d6c9db89b9ee27b9f | |
parent | e2fb11a5cc9a8ace6984c38cd3303371819032be (diff) |
types: gracefully handle unpatched upvalues in ucv_free()
When a module function with unpatched upvalues is freed, ucv_free() might
access a NULL pointer through ucv_put_value(), so make sure to skip those
unset upvalue slots when freeing a closure.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | types.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -266,7 +266,8 @@ ucv_free(uc_value_t *uv, bool retain) ref = &closure->ref; for (i = 0; i < function->nupvals; i++) - ucv_put_value(&closure->upvals[i]->header, retain); + if (closure->upvals[i]) + ucv_put_value(&closure->upvals[i]->header, retain); ucv_put_value(&function->program->header, retain); break; |