Skip to content

Commit 375ce58

Browse files
authored
Fix asan issue. (proxy-wasm#11)
Signed-off-by: John Plevyak <[email protected]>
1 parent c472e92 commit 375ce58

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

include/proxy-wasm/wasm.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ class WasmBase : public std::enable_shared_from_this<WasmBase> {
134134

135135
void addAfterVmCallAction(std::function<void()> f) { after_vm_call_actions_.push_back(f); }
136136
void doAfterVmCallActions() {
137-
while (!after_vm_call_actions_.empty()) {
138-
auto f = std::move(after_vm_call_actions_.front());
139-
after_vm_call_actions_.pop_front();
140-
f();
137+
// NB: this may be deleted by a delayed function unless prevented.
138+
if (!after_vm_call_actions_.empty()) {
139+
auto self = shared_from_this();
140+
while (!self->after_vm_call_actions_.empty()) {
141+
auto f = std::move(self->after_vm_call_actions_.front());
142+
self->after_vm_call_actions_.pop_front();
143+
f();
144+
}
141145
}
142146
}
143147

0 commit comments

Comments
 (0)