aboutsummaryrefslogtreecommitdiff
path: root/vm
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-29 16:56:33 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-29 16:56:33 +0000
commitc4cb45f3ad3fedb4247577cffb3e5b07f41dab02 (patch)
tree822152be03f167edbfeace548fd6dbdfae2ba247 /vm
parent7c367f95c9a46983ed1b97e9ea892f233d592cdf (diff)
downloadovm-c4cb45f3ad3fedb4247577cffb3e5b07f41dab02.tar.gz
ovm-c4cb45f3ad3fedb4247577cffb3e5b07f41dab02.tar.bz2
ovm-c4cb45f3ad3fedb4247577cffb3e5b07f41dab02.zip
Fixed bug where reading operand bytecode may stop prematurely
This is due to checking for equality instead of just greater than in darr->used against darr->available.
Diffstat (limited to 'vm')
-rw-r--r--vm/inst.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/vm/inst.c b/vm/inst.c
index 8394942..d553d57 100644
--- a/vm/inst.c
+++ b/vm/inst.c
@@ -287,13 +287,13 @@ data_t read_type_from_darr(darr_t *darr, data_type_t type)
case DATA_TYPE_NIL:
break;
case DATA_TYPE_BYTE:
- if (darr->used >= darr->available)
+ if (darr->used > darr->available)
// TODO: Error (darr has no space left)
return DBYTE(0);
return DBYTE(darr->data[darr->used++]);
break;
case DATA_TYPE_HWORD:
- if (darr->used + HWORD_SIZE >= darr->available)
+ if (darr->used + HWORD_SIZE > darr->available)
// TODO: Error (darr has no space left)
return DWORD(0);
hword u = 0;
@@ -302,7 +302,7 @@ data_t read_type_from_darr(darr_t *darr, data_type_t type)
return DHWORD(u);
break;
case DATA_TYPE_WORD:
- if (darr->used + WORD_SIZE >= darr->available)
+ if (darr->used + WORD_SIZE > darr->available)
// TODO: Error (darr has no space left)
return DWORD(0);
word w = 0;