Skip to content

Commit a80c6c4

Browse files
HanatoKjhenin
authored andcommitted
fix: fix the out-of-bound access in from_simple_string
This commit ensures that the boundary check happens first.
1 parent f83f1fe commit a80c6c4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/colvartypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ template <class T> class colvarmodule::vector1d
345345
std::stringstream stream(s);
346346
size_t i = 0;
347347
if (this->size()) {
348-
while ((stream >> (*this)[i]) && (i < this->size())) {
348+
while ((i < this->size()) && (stream >> (*this)[i])) {
349349
i++;
350350
}
351351
if (i < this->size()) {

0 commit comments

Comments
 (0)