Skip to content

Commit

Permalink
fixed bounds checks (close #71)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Aug 10, 2017
1 parent 697198c commit 074f110
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ const char *hl_op_name( int op ) {
static char **hl_read_strings( hl_reader *r, int nstrings, int **out_lens ) {
int size = hl_read_i32(r);
hl_code *c = r->code;
char *sdata = (char*)hl_malloc(&c->alloc,sizeof(char) * size);
char *sbase = (char*)hl_malloc(&c->alloc,sizeof(char) * size);
char *sdata = sbase;
char **strings;
int *lens;
int i;
Expand All @@ -368,7 +369,7 @@ static char **hl_read_strings( hl_reader *r, int nstrings, int **out_lens ) {
strings[i] = sdata;
lens[i] = sz;
sdata += sz;
if( sdata >= sdata + size || *sdata )
if( sdata >= sbase + size || *sdata )
EXIT("Invalid string");
sdata++;
}
Expand Down

0 comments on commit 074f110

Please sign in to comment.