Avoid potential wrong memory access

If the user uses an invalid index, the [] operator won't check it and the program will access invalid memory. Using at() would throw instead.
release/4.3a0
Jose Luis Blanco-Claraco 2021-04-27 11:24:46 +02:00 committed by GitHub
parent 32acaecdc9
commit 2b43e7f8f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -355,7 +355,7 @@ class FactorGraph {
/** delete factor without re-arranging indexes by inserting a nullptr pointer
*/
void remove(size_t i) { factors_[i].reset(); }
void remove(size_t i) { factors_.at(i).reset(); }
/** replace a factor by index */
void replace(size_t index, sharedFactor factor) { at(index) = factor; }