diff options
-rw-r--r-- | types.c | 4 | ||||
-rw-r--r-- | vm.c | 4 |
2 files changed, 3 insertions, 5 deletions
@@ -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; @@ -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; |