diff --git a/src/sprs.c b/src/sprs.c index ac9bd33..1166d5a 100644 --- a/src/sprs.c +++ b/src/sprs.c @@ -36,7 +36,7 @@ void sprs_put(sprs* sprs, int index, void* data){ } } 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* data = NULL;