History

String constructor now permits length of 0 with non-null - This was useful when using static buffers that don't have content. Ensure the syscall error message buffer is properly initialized.

arr committed 9 years ago

Commit 058335e1 parent 0643d043 files · +9 −4Browse files

Showing the changes to src/vm/string.cpp (1 of 3 files). Show all

Unified · Split

src/vm/string.cpp+4−1
@@ -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 , _length_max{ sizeof(_mem.local) }190 , _length_max{ sizeof(_mem.local) }
191 , _mem{}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 const auto utf8_length = utf8::count_codepoints(encoded_str, encoded_str_len);197 const auto utf8_length = utf8::count_codepoints(encoded_str, encoded_str_len);
195 198
196 // Check if the supplied string is completely valid UTF-8 - only valid UTF-8 strings can be DisVM strings.199 // Check if the supplied string is completely valid UTF-8 - only valid UTF-8 strings can be DisVM strings.