Skip to content

Commit

Permalink
fix the memory leak issue in VisitListPool allocation (#229)
Browse files Browse the repository at this point in the history
Signed-off-by: jinjiabao.jjb <jinjiabao.jjb@antgroup.com>
  • Loading branch information
inabao authored and jinjiabao.jjb committed Dec 19, 2024
1 parent 3baa6e1 commit 4549cd3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/vsag/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class Allocator {
T*
New(Args&&... args) {
void* p = Allocate(sizeof(T));
return (T*)::new (p) T(std::forward<Args>(args)...);
try {
return (T*)::new (p) T(std::forward<Args>(args)...);
} catch (std::exception& e) {
Deallocate(p);
throw e;
}
}

template <typename T>
Expand Down

0 comments on commit 4549cd3

Please sign in to comment.