Fix check of kdtree loading from disk

This commit is contained in:
Guilhem Lavaux 2022-05-27 16:26:59 +03:00
parent e2a2c7287c
commit 59bb99e7ee

View File

@ -643,8 +643,8 @@ namespace CosmoTool {
throw InvalidOnDiskKDTree();
}
if (node_on_disk.cell_id > numNodes || node_on_disk.cell_id < 0 ||
node_on_disk.children_node[0] > lastNode || node_on_disk.children_node[0] < -1 ||
node_on_disk.children_node[1] > lastNode || node_on_disk.children_node[1] < -1)
(node_on_disk.children_node[0] >= 0 && node_on_disk.children_node[0] > lastNode) || node_on_disk.children_node[0] < -1 ||
(node_on_disk.children_node[1] >= 0 && node_on_disk.children_node[1] > lastNode) || node_on_disk.children_node[1] < -1)
{
delete[] nodes;
std::cerr << "Invalid cell id or children node id invalid" << std::endl;