Skip to content

Commit 7617df4

Browse files
committed
refactor: change code for consistency
1 parent 12a5116 commit 7617df4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

tuple/include/array_of_strings_sketch_impl.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,13 @@ void default_array_of_strings_serde<Allocator>::deserialize(
155155
summary_allocator alloc(summary_allocator_);
156156
std::allocator_traits<summary_allocator>::construct(alloc, &items[i], std::move(array));
157157
}
158-
} catch (...) {
159-
failure = true;
158+
} catch (std::exception& e) {
159+
summary_allocator alloc(summary_allocator_);
160+
for (unsigned j = 0; j < i; ++j) {
161+
std::allocator_traits<summary_allocator>::destroy(alloc, &items[j]);
162+
}
163+
if (std::string(e.what()).find("size exceeds 127") != std::string::npos) throw;
164+
throw std::runtime_error("array_of_strings stream read failed at item " + std::to_string(i));
160165
}
161166
if (failure) {
162167
summary_allocator alloc(summary_allocator_);
@@ -219,9 +224,9 @@ size_t default_array_of_strings_serde<Allocator>::deserialize(
219224
uint32_t length;
220225
bytes_read += copy_from_mem(ptr8 + bytes_read, length);
221226

227+
check_memory_size(bytes_read + length, capacity);
222228
std::string value(length, '\0');
223229
if (length != 0) {
224-
check_memory_size(bytes_read + length, capacity);
225230
bytes_read += copy_from_mem(ptr8 + bytes_read, &value[0], length);
226231
}
227232
array[j] = std::move(value);

0 commit comments

Comments
 (0)