Skip to content

Commit 4dc32ec

Browse files
fix: replace from_utf8_unchecked with from_utf8_lossy in SqliteError (#4202)
sqlite3_errmsg() returns UTF-8 in practice but the spec does not guarantee it. Using from_utf8_unchecked is unsound if non-UTF-8 bytes are returned (e.g. from malformed schema element names). Closes #4193
1 parent 6984316 commit 4dc32ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sqlx-sqlite/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl SqliteError {
3939
let msg = sqlite3_errmsg(handle);
4040
debug_assert!(!msg.is_null());
4141

42-
str::from_utf8_unchecked(CStr::from_ptr(msg).to_bytes()).to_owned()
42+
String::from_utf8_lossy(CStr::from_ptr(msg).to_bytes()).into_owned()
4343
};
4444

4545
Some(Self {

0 commit comments

Comments
 (0)