Skip to content

Commit e2e16a5

Browse files
bartlomiejuclaude
andcommitted
fix: DispatchResult memory leak and remove dead code
- Fix DispatchResult::run() leaking the wrapper (was using mem::forget instead of letting Drop clean up) - Remove unused UberDispatcher::as_raw() method - Add compile-time static_assert for FrontendChannel BASE size Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 96d7c9a commit e2e16a5

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/crdtp.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl DispatchResult {
496496
unsafe {
497497
crdtp__DispatchResult__Run(self.ptr);
498498
}
499-
std::mem::forget(self);
499+
// Drop will call crdtp__DispatchResult__DELETE to free the wrapper.
500500
}
501501
}
502502

@@ -530,10 +530,6 @@ impl UberDispatcher {
530530
}
531531
}
532532

533-
/// Get the raw pointer for passing to C++ Wire functions.
534-
pub fn as_raw(&mut self) -> *mut Self {
535-
self as *mut Self
536-
}
537533
}
538534

539535
impl Drop for UberDispatcher {

src/crdtp_binding.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ struct crdtp__FrontendChannel__BASE : public FrontendChannel {
4343
}
4444
};
4545

46+
static_assert(sizeof(crdtp__FrontendChannel__BASE) <= sizeof(void*),
47+
"FrontendChannel BASE must fit in a single vtable pointer");
48+
4649
extern "C" {
4750

4851
void crdtp__FrontendChannel__BASE__CONSTRUCT(

0 commit comments

Comments
 (0)