Skip to content

Commit

Permalink
Fix double free when passing unique_ptr by value
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jan 19, 2024
1 parent f540614 commit 8b0a1ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/bytedeco/javacpp/tools/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ boolean classes(boolean handleExceptions, boolean defineAdapters, boolean conver
out.println(" return (typename UNIQUE_PTR_NAMESPACE::remove_const<T>::type*)ptr;");
out.println(" }");
out.println(" operator U&() const { return uniquePtr; }");
out.println(" operator U&&() { return UNIQUE_PTR_NAMESPACE::move(uniquePtr); }");
out.println(" operator U&&() { owner = NULL; return UNIQUE_PTR_NAMESPACE::move(uniquePtr); }");
out.println(" operator U*() { return &uniquePtr; }");
out.println(" T* ptr;");
out.println(" size_t size;");
Expand Down Expand Up @@ -1437,7 +1437,7 @@ boolean classes(boolean handleExceptions, boolean defineAdapters, boolean conver
out.println(" return ptr;");
out.println(" }");
out.println(" operator const T*() { return ptr; }");
out.println(" operator T&&() { return MOVE_NAMESPACE::move(movedPtr); }");
out.println(" operator T&&() { owner = NULL; return MOVE_NAMESPACE::move(movedPtr); }");
out.println(" T* ptr;");
out.println(" size_t size;");
out.println(" void* owner;");
Expand Down

0 comments on commit 8b0a1ce

Please sign in to comment.