Skip to content

Commit a6dee1a

Browse files
committed
Don't assume errors are utf-8
Apparently sometimes they aren't! Closes #324
1 parent 3ac7970 commit a6dee1a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ impl Error {
5858

5959
unsafe fn from_raw(code: c_int, ptr: *const raw::git_error) -> Error {
6060
let msg = CStr::from_ptr((*ptr).message as *const _).to_bytes();
61-
let msg = str::from_utf8(msg).unwrap();
62-
Error { code: code, klass: (*ptr).klass, message: msg.to_string() }
61+
let msg = String::from_utf8_lossy(msg).into_owned();
62+
Error { code: code, klass: (*ptr).klass, message: msg }
6363
}
6464

6565
/// Creates a new error from the given string as the error.

0 commit comments

Comments
 (0)