[libcxx-commits] [PATCH] D138601: [libc++] Fix memory leaks when throwing inside std::vector constructors

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 29 12:20:57 PST 2022


var-const added a comment.

@philnik Thanks a lot for fixing this! Just to double-check -- you have considered reintroducing the base class for the purpose of providing exception safety and decided that using transactions is better, right? (I presume it is, since you would probably need to move quite a few details related to memory management back into the base class for this to work)



================
Comment at: libcxx/include/vector:1256
 {
+    auto __guard = std::__make_transaction(__destroy_vector(*this));
     std::__debug_db_insert_c(this);
----------------
Optional: maybe add a helper function so that this can be:
```
auto __guard = __create_guard(*this);
```
The expression is not super verbose, but it's repeated _a lot_.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138601/new/

https://reviews.llvm.org/D138601



More information about the libcxx-commits mailing list