Skip to content

Commit

Permalink
Add workaround for string offset bug in ruby 3.2+ on Windows
Browse files Browse the repository at this point in the history
Ref: #340
  • Loading branch information
acj committed Dec 31, 2023
1 parent e985228 commit 1b965b4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/ruby_version.rs
Expand Up @@ -643,6 +643,10 @@ macro_rules! get_ruby_string_3_2_0(
// See RSTRING_NOEMBED and RUBY_FL_USER1
let is_embedded_string = rstring.basic.flags & 1 << 13 == 0;
if is_embedded_string {
// Workaround for Windows strings until we have OS-specific bindings
#[cfg(target_os = "windows")]
let addr = addr + 4;

// The introduction of Variable Width Allocation (VWA) for strings means that
// the length of embedded strings varies at runtime. Instead of assuming a
// constant length, we need to read the length from the struct.
Expand Down Expand Up @@ -675,6 +679,10 @@ macro_rules! get_ruby_string_3_3_0(
// See RSTRING_NOEMBED and RUBY_FL_USER1
let is_embedded_string = rstring.basic.flags & 1 << 13 == 0;
if is_embedded_string {
// Workaround for Windows strings until we have OS-specific bindings
#[cfg(target_os = "windows")]
let addr = addr + 4;

// The introduction of Variable Width Allocation (VWA) for strings means that
// the length of embedded strings varies at runtime. Instead of assuming a
// constant length, we need to read the length from the struct.
Expand Down

0 comments on commit 1b965b4

Please sign in to comment.