Skip to content

Commit b0aa0ce

Browse files
don't panic on utf8 error
1 parent b334c37 commit b0aa0ce

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.14.4
2+
3+
* don't panic on utf8 error in to_str
4+
15
# 0.14.3
26

37
* update quickjs-ng to 0.6.0

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "quickjs_runtime"
3-
version = "0.14.3"
3+
version = "0.14.4"
44
authors = ["Andries Hiemstra <info@hirofa.com>"]
55
edition = "2021"
66
description = "Wrapper API and utils for the QuickJS JavaScript engine with support for Promise, Modules, Async/await"

src/quickjs_utils/primitives.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ pub unsafe fn to_str(
124124
}
125125

126126
let cstr = std::ffi::CStr::from_ptr(ptr);
127-
Ok(cstr.to_str().expect("bad cstr bad!"))
127+
cstr.to_str()
128+
.map_err(|e| JsError::new_string(format!("utf8 error: {e}")))
128129

129130
//let s = cstr.to_string_lossy();
130131

0 commit comments

Comments
 (0)