summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-08-24 15:31:11 +0200
committerJo-Philipp Wich <jo@mein.io>2022-08-24 15:33:18 +0200
commitc43a54f6dc45590ce553a294ae59bd14324212f2 (patch)
tree42aac8229c6679983beada2d6c9db89b9ee27b9f
parente2fb11a5cc9a8ace6984c38cd3303371819032be (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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/types.c b/types.c
index e05d685..5274d23 100644
--- a/types.c
+++ b/types.c
@@ -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;