Skip to content

[std] hl haxe.io.BytesBuffer.__expand check overflow #12267

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

Conversation

yuxiaomao
Copy link
Contributor

by Nicolas

Without this, the program give access violation on expand very large buffer.

@Simn
Copy link
Member

Simn commented Jun 9, 2025

I can tell that it's by Nicolas because there's an error I can't make sense of. Help me out here, what's the size >> 10 doing there...

@yuxiaomao
Copy link
Contributor Author

I believe it's for displaying the current buffer size in KBytes instead of in Bytes (>>10 = /1024). I'm totally ok if we just display it in Bytes too x)

@Simn
Copy link
Member

Simn commented Jun 10, 2025

But won't this just become 0 for anything < 1024?

@yuxiaomao
Copy link
Contributor Author

Yes, but this error is only thrown if (size*3) >>> 1 overflow and becomes smaller than pos (which is smaller or equal than size).

@Simn
Copy link
Member

Simn commented Jun 10, 2025

Ah, I get it now. I thought the value was relative because it says "expand". In that case this is fine.

@Simn Simn merged commit a9dbe27 into HaxeFoundation:development Jun 10, 2025
92 of 93 checks passed
@yuxiaomao yuxiaomao deleted the dev-hl-bytesbuffer-overflow branch June 10, 2025 06:20
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