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

use better overflow check #2768

Merged
merged 1 commit into from
Dec 29, 2024
Merged

Conversation

mulle-nat
Copy link
Contributor

This is a better mergable #2767, but my fork got out of sync and there were superflous commits in there. Sorry for the inconvenience. Here's my original comment.

I think you will like this much better. The other code was more or less a mitigation but this
should be a better overflow checker. The multiplication does the zero check and the
comparison checks that the multiplication doesn't overflow. calloc will then do the other
overflow check.

Adding to this: The old code caught overflow with large negative numbers, but this one will catch any kind of overflow. Also the code is easier to understand IMO.

@dankamongmen
Copy link
Owner

if we're really committing to this catch overflow idea, don't we want it backing ncplane_create(), and thus handling all ncplane creations?

@dankamongmen dankamongmen self-assigned this Mar 3, 2024
@dankamongmen
Copy link
Owner

if we're really committing to this catch overflow idea, don't we want it backing ncplane_create(), and thus handling all ncplane creations?

nevermind, i think it is by virtue of being in ncplane_new_internal()

src/lib/notcurses.c Show resolved Hide resolved
src/lib/notcurses.c Show resolved Hide resolved
@mulle-nat
Copy link
Contributor Author

Just wondering, if I need to add some more comments here, or if everything is clear.

@dankamongmen
Copy link
Owner

nope, i just took a long break from notcurses. doing a quick review and probably merging!

@dankamongmen dankamongmen merged commit bf5e74c into dankamongmen:master Dec 29, 2024
2 of 3 checks passed
@dankamongmen
Copy link
Owner

Thank you for your contribution! Sorry for the long delay!

dankamongmen added a commit that referenced this pull request Dec 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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.

None yet

2 participants