proost commented on code in PR #569:
URL: https://github.com/apache/datasketches-cpp/pull/569#discussion_r4521707947


##########
kll/include/kll_sketch_impl.hpp:
##########
@@ -425,7 +435,11 @@ auto kll_sketch<T, C, A>::serialize(unsigned 
header_size_bytes, const SerDe& sd)
       ptr += copy_to_mem(min_k_, ptr);
       ptr += copy_to_mem(num_levels_, ptr);
       ptr += sizeof(uint8_t); // unused
-      ptr += copy_to_mem(levels_.data(), ptr, sizeof(levels_[0]) * 
num_levels_);
+      if (items_size_ < k_) {

Review Comment:
   here too.



##########
kll/include/kll_sketch_impl.hpp:
##########
@@ -389,7 +395,11 @@ void kll_sketch<T, C, A>::serialize(std::ostream& os, 
const SerDe& sd) const {
     write(os, min_k_);
     write(os, num_levels_);
     write(os, unused);
-    write(os, levels_.data(), sizeof(levels_[0]) * num_levels_);
+    if (items_size_ < k_) {

Review Comment:
   We also guard num_levels_ == 1



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to