Skip to content

Commit

Permalink
Try #432:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed May 10, 2019
2 parents 7f61eaf + 1d55530 commit e7416c0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/runtime-c-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ pub unsafe extern "C" fn wasmer_last_error_message(buffer: *mut c_char, length:
return -1;
}

let last_error = match take_last_error() {
Some(err) => err,
let error_message = match take_last_error() {
Some(err) => err.to_string(),
None => return 0,
};

let error_message = last_error.to_string();
let length = length as usize;

let buffer = slice::from_raw_parts_mut(buffer as *mut u8, length as usize);

if error_message.len() >= buffer.len() {
// buffer to small for err message
if error_message.len() >= length {
// buffer to small to hold the error message
return -1;
}

let buffer = slice::from_raw_parts_mut(buffer as *mut u8, length);

ptr::copy_nonoverlapping(
error_message.as_ptr(),
buffer.as_mut_ptr(),
Expand Down

0 comments on commit e7416c0

Please sign in to comment.