Skip to content

Minor fix for Allocator.remap and mem.bytesAsSlice for zero-sized types #23220

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 2 commits into from
Mar 25, 2025

Conversation

samy-00007
Copy link
Contributor

This PR does 3 things:

  • for Allocator.remap, if the type is zero-sized, then it only changes the slice's length
  • for mem.bytesAsSlice, if the type is zero-sized, it returns a slice with a length of zero (instead of crashing because of a division by zero)
  • added a test for the 2 first points and one for json parsing with zero-sized types

Fixes #23168

@alexrp alexrp added this to the 0.14.1 milestone Mar 13, 2025
@alexrp
Copy link
Member

alexrp commented Mar 24, 2025

Can you please squash the relevant parts of be1acb6 into the two prior commits?

Copy link
Member

@alexrp alexrp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise.

@samy-00007
Copy link
Contributor Author

Like that ?

@alexrp
Copy link
Member

alexrp commented Mar 24, 2025

I meant to split it up and amend the relevant formatting fixes into the two previous commits, since it's fixing formatting in both.

@samy-00007
Copy link
Contributor Author

Oh sorry, should be good now.

@alexrp alexrp enabled auto-merge March 24, 2025 21:20
@alexrp alexrp merged commit e1c6af2 into ziglang:master Mar 25, 2025
9 checks passed
alexrp added a commit that referenced this pull request Mar 25, 2025
Minor fix for `Allocator.remap` and `mem.bytesAsSlice` for zero-sized types
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.

std.json.parseFromSlice divide by zero
3 participants