File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1111,7 +1111,9 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
11111111 tableint *datal = (tableint *) (data + 1 );
11121112 HNSWLIB_MM_PREFETCH (getDataByInternalId (*datal), _MM_HINT_T0);
11131113 for (int i = 0 ; i < size; i++) {
1114- HNSWLIB_MM_PREFETCH (getDataByInternalId (*(datal + i + 1 )), _MM_HINT_T0);
1114+ if (i + 1 < size) {
1115+ HNSWLIB_MM_PREFETCH (getDataByInternalId (*(datal + i + 1 )), _MM_HINT_T0);
1116+ }
11151117 tableint cand = datal[i];
11161118 dist_t d = fstdistfunc_ (dataPoint, getDataByInternalId (cand), dist_func_param_);
11171119 if (d < curdist) {
Original file line number Diff line number Diff line change @@ -437,7 +437,13 @@ class ChunkedArray {
437437 }
438438
439439 char * operator [](size_t i) const {
440+ #ifndef NDEBUG
441+ if (i >= getCapacity ()) {
442+ HNSWERR << " Chunked array index out of range: i=" << i
443+ << " , capacity=" << getCapacity () << std::endl;
444+ }
440445 assert (i < getCapacity ());
446+ #endif
441447 if (i >= getCapacity ()) return nullptr ;
442448 size_t chunk_index = i / elements_per_chunk_;
443449 size_t index_in_chunk = i % elements_per_chunk_;
You can’t perform that action at this time.
0 commit comments