diff --git a/src/cavepacker/shared/BoardState.h b/src/cavepacker/shared/BoardState.h index a5741539f..05df29fa8 100644 --- a/src/cavepacker/shared/BoardState.h +++ b/src/cavepacker/shared/BoardState.h @@ -107,6 +107,8 @@ class BoardState { * @return @c false if the conversion failed because the index isn't part of the board */ inline bool getColRowFromIndex(int index, int& col, int& row) const { + if (index < 0 || index >= _state.size()) + return false; if (_state[index] == '\0') return false; col = index % _width;