Showing the changes to src/vm/string.cpp (1 of 5 files). Show all
Unified · Split
| @@ -397,7 +397,7 @@ word_t vm_string_t::get_length() const · 396 unmodified lines | |||
| 397 | 397 | ||
| 398 | runtime::rune_t vm_string_t::get_rune(word_t index) const | 398 | runtime::rune_t vm_string_t::get_rune(word_t index) const |
| 399 | { | 399 | { |
| 400 | if (index < 0 && _length <= index) | 400 | if (index < 0 || _length <= index) |
| 401 | throw index_out_of_range_memory{ 0, _length - 1, index }; | 401 | throw index_out_of_range_memory{ 0, _length - 1, index }; |
| 402 | 402 | ||
| 403 | // Determine if local or allocated memory | 403 | // Determine if local or allocated memory |
| @@ -423,7 +423,7 @@ void vm_string_t::set_rune(word_t index, rune_t value) · 19 unmodified lines | |||
| 423 | throw invalid_utf8{}; | 423 | throw invalid_utf8{}; |
| 424 | 424 | ||
| 425 | // Index equal to length is allowed to grow the string | 425 | // Index equal to length is allowed to grow the string |
| 426 | if (index < 0 && _length <= index) | 426 | if (index < 0 || _length < index) |
| 427 | throw index_out_of_range_memory{ 0, _length, index }; | 427 | throw index_out_of_range_memory{ 0, _length, index }; |
| 428 | 428 | ||
| 429 | // Determine if local or allocated memory | 429 | // Determine if local or allocated memory |