Skip to content

Fix issue overflow when reading data#21

Merged
bertmelis merged 5 commits intobertmelis:mainfrom
urbytes21:main
Feb 6, 2026
Merged

Fix issue overflow when reading data#21
bertmelis merged 5 commits intobertmelis:mainfrom
urbytes21:main

Conversation

@urbytes21
Copy link
Contributor

No description provided.

@urbytes21
Copy link
Contributor Author

Hi @bertmelis ,
size is the target read size, retVal is the bytes already read,
So I think we should change the loop condition to while (size > retVal) instead of checking pxItemSize.

Please help me review this PR.
Many thanks.

@bertmelis
Copy link
Owner

Thanks!

I'm a bit struggling with an off-by-1 buffer usage because a check for buffer size greater than retval instead of greater or equal. When eventually size - retVal reaches 0, the function returns NULL and we exit the loop.

@urbytes21
Copy link
Contributor Author

Hi @bertmelis ,
Thanks for pointing this out. The logic itself is correct, and there’s no off-by-one issue, but I agree it’s a bit unclear to rely on a zero-length receive returning NULL to exit the loop.

I've updated to make it clearer. Please help me review.
Thank you.

@bertmelis bertmelis merged commit e54100b into bertmelis:main Feb 6, 2026
3 checks passed
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