Fix two crash conditions Ampere found. These are just temporary
patches; my private version has rewritten both of these functions (ironically fixing these bugs in the process) to handle negative offsets meaning "from the end".
This commit is contained in:
parent
04c5f2c36a
commit
f4b05d46ed
@ -64,7 +64,7 @@ static naRef stringify(struct Context* ctx, naRef r)
|
||||
static int checkVec(struct Context* ctx, naRef vec, naRef idx)
|
||||
{
|
||||
int i = (int)numify(ctx, idx);
|
||||
if(i < 0 || i >= vec.ref.ptr.vec->rec->size)
|
||||
if(i < 0 || !vec.ref.ptr.vec->rec || i >= vec.ref.ptr.vec->rec->size)
|
||||
ERR(ctx, "vector index out of bounds");
|
||||
return i;
|
||||
}
|
||||
|
@ -115,6 +115,7 @@ static naRef substr(naContext c, naRef me, int argc, naRef* args)
|
||||
start = (int)startR.num;
|
||||
if(naIsNil(lenR)) {
|
||||
len = naStr_len(src) - start;
|
||||
if(len < 0) return naNil();
|
||||
} else {
|
||||
lenR = naNumValue(lenR);
|
||||
if(naIsNil(lenR)) return naNil();
|
||||
|
Loading…
Reference in New Issue
Block a user