Skip to content

Commit

Permalink
enable patched feature for quick-js
Browse files Browse the repository at this point in the history
Otherwise, in some cases, QuickJS will reports stack overflow.
  • Loading branch information
xu-cheng committed Feb 7, 2020
1 parent 7d1daaf commit 887de4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ categories = ["api-bindings"]

[dependencies]
derive_builder = "0.9.0"
quick-js = "0.3.0"
quick-js = { version = "0.3.0", features = ["patched"] }
thiserror = "1.0"
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,4 +519,19 @@ mod tests {
assert!(!html.contains(r#"color:#ff0000"#));
assert!(html.contains(r#"a href="https://www.google.com""#));
}

#[test]
fn test_stack_overflow() {
#[inline(never)]
fn simulate_deep_stack(i: i32) {
if i > 0 {
simulate_deep_stack(i - 1);
} else {
let html = render("a = b + c").unwrap();
assert!(html.contains(r#"span class="katex""#));
}
}
simulate_deep_stack(100);
simulate_deep_stack(0);
}
}

0 comments on commit 887de4c

Please sign in to comment.