summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--types.c4
-rw-r--r--vm.c4
2 files changed, 3 insertions, 5 deletions
diff --git a/types.c b/types.c
index 1247268..4e17025 100644
--- a/types.c
+++ b/types.c
@@ -963,7 +963,7 @@ ucv_ressource_type_add(const char *name, uc_value_t *proto, void (*freefn)(void
static uc_ressource_type_t *
ucv_ressource_type_get(size_t type)
{
- return (type < res_types.count) ? &res_types.entries[type] : NULL;
+ return (type > 0 && type <= res_types.count) ? &res_types.entries[type - 1] : NULL;
}
uc_ressource_type_t *
@@ -987,7 +987,7 @@ ucv_ressource_new(uc_ressource_type_t *type, void *data)
res = xalloc(sizeof(*res));
res->header.type = UC_RESSOURCE;
res->header.refcount = 1;
- res->type = type - res_types.entries;
+ res->type = type ? (type - res_types.entries) + 1 : 0;
res->data = data;
return &res->header;
diff --git a/vm.c b/vm.c
index 10e3286..88c537c 100644
--- a/vm.c
+++ b/vm.c
@@ -1807,10 +1807,8 @@ uc_vm_insn_next(uc_vm *vm, enum insn_type insn)
abort();
}
- if (k == NULL) {
+ if (k == NULL)
k = ucv_ressource_new(NULL, NULL);
- ((uc_ressource_t *)k)->type = UINT64_MAX;
- }
iterk = (uc_ressource_t *)k;