dfhack
dfhack copied to clipboard
result of `binsearch_index` used without validation in `Eventmgr.cpp`
size_t idx = df::report::binsearch_index(reports, lastReportUnitAttack, false);
// returns the index to the key equal to or greater than the key provided
idx = reports[idx]->id == lastReportUnitAttack ? idx + 1 : idx; // we need the index after (where the new stuff is)
idx may be -1 here if the report ID was not found in the relevant index, however, this code uses idx without validating the results of the search function
this is another one of those cases where we're assuming DF data structures are well-ordered, and getting burned because they're not