diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index 52bb3ea9b..3dc16ff26 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -134,14 +134,11 @@ wcstring parse_error_t::describe(const wcstring &src, bool is_interactive) const } void parse_error_offset_source_start(parse_error_list_t *errors, size_t amt) { - assert(errors != nullptr); - if (amt > 0) { - size_t i, max = errors->size(); - for (i = 0; i < max; i++) { - parse_error_t *error = &errors->at(i); + if (amt > 0 && errors != nullptr) { + for (parse_error_t &error : *errors) { // Preserve the special meaning of -1 as 'unknown'. - if (error->source_start != SOURCE_LOCATION_UNKNOWN) { - error->source_start += amt; + if (error.source_start != SOURCE_LOCATION_UNKNOWN) { + error.source_start += amt; } } }