summaryrefslogtreecommitdiffhomepage
path: root/lib.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-03-25 14:37:58 +0100
committerJo-Philipp Wich <jo@mein.io>2021-03-25 14:40:24 +0100
commit9a6ef2bf3f9d0cabe39a05c72f70fc1799258c0f (patch)
tree20e454fc34f4ec5a14bc8b22f9a3e4db7cf2f063 /lib.c
parent03f132427bffa96099611897c7c8ade279639874 (diff)
lib: prevent use-after-free after uc_shift()
Make sure to increase the refcount of items being moved since the subsequent put operation will decrease it, prematurely freeing moved items which will lead to use-after-free errors later on. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 2d96aa3..23141a3 100644
--- a/lib.c
+++ b/lib.c
@@ -470,7 +470,7 @@ uc_shift(uc_vm *vm, size_t nargs)
for (arridx = 0; arridx < arrlen - 1; arridx++)
json_object_array_put_idx(arr, arridx,
- json_object_array_get_idx(arr, arridx + 1));
+ uc_value_get(json_object_array_get_idx(arr, arridx + 1)));
json_object_array_del_idx(arr, arrlen - 1, 1);
#ifdef HAVE_ARRAY_SHRINK