Skip to content

Commit

Permalink
fix possible segfault when checking runtime's version (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoGiachetta authored Jan 8, 2025
1 parent a561062 commit 6a4efaf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ pub unsafe extern "C" fn cairo_native__get_version(target: *mut u8, length: usiz
let version = env!("CARGO_PKG_VERSION");
assert!(length > version.len(), "version buffer not big enough");

let target = slice::from_raw_parts_mut(target, version.len());
let target = slice::from_raw_parts_mut(target, length);

target.copy_from_slice(version.as_bytes());
target[..version.len()].copy_from_slice(version.as_bytes());
target[version.len()] = b'\0';

version.len()
Expand Down

0 comments on commit 6a4efaf

Please sign in to comment.