Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracing/js: distinguish stack oob error #219

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/tracing/js/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,22 @@ impl StackRef {
fn peek(&self, idx: usize, ctx: &mut Context) -> JsResult<JsValue> {
self.0
.with_inner(|stack| {
let value = stack.peek(idx).map_err(|_| {
JsError::from_native(JsNativeError::typ().with_message(format!(
"tracer accessed out of bound stack: size {}, index {}",
stack.len(),
idx
)))
})?;
to_bigint(value, ctx)
stack
.peek(idx)
.map_err(|_| {
JsError::from_native(JsNativeError::typ().with_message(format!(
"tracer accessed out of bound stack: size {}, index {}",
stack.len(),
idx
)))
})
.and_then(|value| to_bigint(value, ctx))
})
.ok_or_else(|| {
JsError::from_native(JsNativeError::typ().with_message(format!(
"tracer accessed out of bound stack: size 0, index {}",
idx
)))
JsError::from_native(
JsNativeError::typ()
.with_message("tracer accessed stack after it was dropped".to_string()),
)
})?
}

Expand All @@ -465,9 +467,7 @@ impl StackRef {
let idx = idx_f64 as usize;
if len <= idx || idx_f64 < 0. {
return Err(JsError::from_native(JsNativeError::typ().with_message(
format!(
"tracer accessed out of bound stack: size {len}, index {idx_f64}"
),
format!("tracer accessed out of bound stack: size {len}, index {idx}"),
)));
}
stack.peek(idx, ctx)
Expand Down
Loading