Skip to content
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

Comparison between signed and unsigned integer expressions #8

Open
funktioniert opened this issue Jan 21, 2016 · 1 comment
Open

Comparison between signed and unsigned integer expressions #8

funktioniert opened this issue Jan 21, 2016 · 1 comment

Comments

@funktioniert
Copy link
Contributor

const auto area = egptr() - dest < put_back_size_ ? egptr() - dest : put_back_size_;
contains an comparison between signed and unsigned integer expressions.

This could potentially lead to an integer underflow, resulting in memmoving a large area.
Maybe add a test for area < 0?

@ztdwu
Copy link
Contributor

ztdwu commented Jan 21, 2016

Yes, we could have that error if egptr() - dest < 0, although I don't think that will ever happen looking at the code. Still, it would be nice to explicitly cast all signed/unsigned comparisons just for the peace of mind.

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

No branches or pull requests

2 participants