Skip to content

Conversation

ankane
Copy link
Contributor

@ankane ankane commented Apr 22, 2025

Also added more tests for the current behavior.

require "fiddle"

ptr = Fiddle::Pointer["hello\0world"]
ptr.size = 0

p (ptr + 1).size
p (ptr + 1).to_s(5)
p (ptr + 1).to_s
p (ptr + 1).to_str(5)
p (ptr + 1).to_str

Output

-1
"ello\x00"
"ello"
"ello\x00"
repro.rb:10:in 'Fiddle::Pointer#to_str': negative string size (or size too big) (ArgumentError)

@kou kou merged commit 47be73d into ruby:master Apr 22, 2025
62 of 66 checks passed
@kou
Copy link
Member

kou commented Apr 22, 2025

Thanks.

@ankane
Copy link
Contributor Author

ankane commented Apr 22, 2025

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants