Skip to content

Make to_str consistent between backends for negative pointer sizes #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

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