Add two extra checks to ensure there are no negative array indices.
This commit is contained in:
parent
5247394d35
commit
0271248472
|
@ -36,7 +36,7 @@ void sprs_put(sprs* sprs, int index, void* data){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int sprs_contains(sprs* sprs, int index){
|
int sprs_contains(sprs* sprs, int index){
|
||||||
return sprs->sparse[index].index < sprs->size && sprs->dense[sprs->sparse[index].index] == index;
|
return index >= 0 && sprs->sparse[index].index >= 0 && sprs->sparse[index].index < sprs->size && sprs->dense[sprs->sparse[index].index] == index;
|
||||||
}
|
}
|
||||||
void* sprs_get(sprs* sprs, int index){
|
void* sprs_get(sprs* sprs, int index){
|
||||||
void* data = NULL;
|
void* data = NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user