Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ std::vector<bool> PQFlashIndex<T, LabelT>::read_nodes(const std::vector<uint32_t
{
uint32_t *node_nhood = offset_to_node_nhood(node_buf);
auto num_nbrs = *node_nhood;
// Validate num_nbrs is within expected bounds
if (num_nbrs > _max_degree)
{
std::stringstream stream;
stream << "Corrupt or mismatched index data detected: num_nbrs (" << num_nbrs
<< ") exceeds max_degree (" << _max_degree << "). "
<< "This may indicate a data type mismatch - ensure the data_type parameter "
<< "matches the type used when building the index.";
throw diskann::ANNException(stream.str(), -1, __FUNCSIG__, __FILE__, __LINE__);
}
nbr_buffers[i].first = num_nbrs;
memcpy(nbr_buffers[i].second, node_nhood + 1, num_nbrs * sizeof(uint32_t));
}
Expand Down
Loading