fix UTF-16 decoding bug again

This commit is contained in:
Martin Michelsen
2023-11-16 23:22:51 -08:00
parent 132395a53a
commit 6b1a3e615b
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ string TextTranscoder::operator()(const void* src, size_t src_size) {
const void* orig_src = src; const void* orig_src = src;
deque<string> blocks; deque<string> blocks;
while (src_size > 0) { while (src_size > 0) {
// Assume 2x input size on average, but always alocate at least 4 bytes // Assume 2x input size on average, but always allocate at least 4 bytes
string& block = blocks.emplace_back(max<size_t>((src_size << 2), 4), '\0'); string& block = blocks.emplace_back(max<size_t>((src_size << 2), 4), '\0');
char* dest = block.data(); char* dest = block.data();
size_t dest_size = block.size(); size_t dest_size = block.size();
+2 -2
View File
@@ -25,7 +25,7 @@ public:
size_t bytes_read; size_t bytes_read;
size_t bytes_written; size_t bytes_written;
}; };
Result operator()(void* dest, size_t dest_size, const void* src, size_t src_bytes, bool truncate_oversize_result); Result operator()(void* dest, size_t dest_bytes, const void* src, size_t src_bytes, bool truncate_oversize_result);
std::string operator()(const void* src, size_t src_bytes); std::string operator()(const void* src, size_t src_bytes);
std::string operator()(const std::string& data); std::string operator()(const std::string& data);
@@ -465,7 +465,7 @@ struct pstring {
} }
for (size_t z = 0; z < Bytes; z += 2) { for (size_t z = 0; z < Bytes; z += 2) {
if (!this->data[z] && !this->data[z + 1]) { if (!this->data[z] && !this->data[z + 1]) {
return z; return z >> 1;
} }
} }
return Bytes >> 1; return Bytes >> 1;