File tree Expand file tree Collapse file tree
crates/guest-rust/src/rt/async_support Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,6 +133,12 @@ impl<O: StreamOps> AbiBuffer<O> {
133133 let ( mut ptr, len) = self . abi_ptr_and_len ( ) ;
134134 assert ! ( amt <= len) ;
135135 for _ in 0 ..amt {
136+ // Update self.cursor incrementally for exception safety.
137+ // When `self.ops.dealloc_lists` panics (which is a user-provided
138+ // callback), we can make sure any item before (including the
139+ // panic one) will not be dealloced again, and the remaining items
140+ // can still get advanced properly.
141+ self . cursor += 1 ;
136142 // SAFETY: we're managing the pointer passed to `dealloc_lists` and
137143 // it was initialized with a `lower`, and then the pointer
138144 // arithmetic should all be in-bounds.
@@ -141,7 +147,6 @@ impl<O: StreamOps> AbiBuffer<O> {
141147 ptr = ptr. add ( self . ops . elem_layout ( ) . size ( ) ) ;
142148 }
143149 }
144- self . cursor += amt;
145150 }
146151
147152 fn take_vec ( & mut self ) -> Vec < O :: Payload > {
You can’t perform that action at this time.
0 commit comments