Adjust fuel consumption to be empty when fuel is 0 (#5013)
Co-authored-by: Jamey Sharp <jsharp@fastly.com> Co-authored-by: Jamey Sharp <jsharp@fastly.com>
This commit is contained in:
@@ -787,7 +787,8 @@ impl Drop for SignalOnDrop {
|
||||
}
|
||||
}
|
||||
|
||||
fn set_fuel<T>(store: &mut Store<T>, fuel: u64) {
|
||||
/// Set the amount of fuel in a store to a given value
|
||||
pub fn set_fuel<T>(store: &mut Store<T>, fuel: u64) {
|
||||
// Determine the amount of fuel already within the store, if any, and
|
||||
// add/consume as appropriate to set the remaining amount to` fuel`.
|
||||
let remaining = store.consume_fuel(0).unwrap();
|
||||
|
||||
@@ -1434,7 +1434,7 @@ impl StoreOpaque {
|
||||
.ok()
|
||||
.and_then(|fuel| consumed_ptr.checked_add(fuel))
|
||||
{
|
||||
Some(consumed) if consumed < 0 => {
|
||||
Some(consumed) if consumed <= 0 => {
|
||||
*consumed_ptr = consumed;
|
||||
Ok(u64::try_from(-consumed).unwrap())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user