Showing the changes to src/vm/string.cpp (1 of 3 files). Show all
Unified · Split
| @@ -190,7 +190,10 @@ vm_string_t::vm_string_t(std::size_t encoded_str_len, const uint8_t *encoded_str · 189 unmodified lines | ||
| 190 | 190 | , _length_max{ sizeof(_mem.local) } |
| 191 | 191 | , _mem{} |
| 192 | 192 | { |
| 193 | − assert((encoded_str_len > 0 && encoded_str != nullptr) || (encoded_str_len == 0 && encoded_str == nullptr)); | |
| 193 | + assert((encoded_str_len > 0 && encoded_str != nullptr) || encoded_str_len == 0); | |
| 194 | + if (encoded_str_len == 0) | |
| 195 | + encoded_str = nullptr; | |
| 196 | + | |
| 194 | 197 | const auto utf8_length = utf8::count_codepoints(encoded_str, encoded_str_len); |
| 195 | 198 | |
| 196 | 199 | // Check if the supplied string is completely valid UTF-8 - only valid UTF-8 strings can be DisVM strings. |