You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by GitBox <gi...@apache.org> on 2021/04/20 01:00:05 UTC

[GitHub] [datasketches-cpp] alexey-milovidov edited a comment on issue #210: `theta_update_sketch_base` is not exception safe.

alexey-milovidov edited a comment on issue #210:
URL: https://github.com/apache/datasketches-cpp/issues/210#issuecomment-822892267


   Memory leak is also suspected here:
   
   ```
     EN* old_entries = entries_;        <-- old_entries are owned by no one
     entries_ = allocator_.allocate(new_size);      <-- if exception is thrown, memory is leaked
     for (size_t i = 0; i < new_size; ++i) EK()(entries_[i]) = 0;
     num_entries_ = 0;
     for (size_t i = 0; i < old_size; ++i) {
       const uint64_t key = EK()(old_entries[i]);
       if (key != 0) {
         insert(find(key).first, std::move(old_entries[i])); // consider a special insert with no comparison
         old_entries[i].~EN();
       }
     }
     allocator_.deallocate(old_entries, old_size);
   ```


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org