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

fix: -Wunsafe-buffer-usage warnings in GetNextZoomLevel() #44149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented Oct 8, 2024

Description of Change

Fixup to #43803 / e894839 that actually fixes the warning.

Takeaway lesson: give the compiler enough information to know that the array indices are always in the array's valid range.

Warnings fixed by this PR:

2024-10-04T05:18:49.7736915Z ../../electron/shell/browser/ui/inspectable_web_contents.cc:132:46: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage]
2024-10-04T05:18:49.7737765Z   132 |       return blink::ZoomFactorToZoomLevel(*--iter);
2024-10-04T05:18:49.7738163Z       |                                              ^~~~
2024-10-04T05:18:49.7738801Z ../../electron/shell/browser/ui/inspectable_web_contents.cc:132:46: note: See //docs/unsafe_buffers.md for help.
2024-10-04T05:18:49.7739875Z ../../electron/shell/browser/ui/inspectable_web_contents.cc:133:19: error: unsafe pointer arithmetic [-Werror,-Wunsafe-buffer-usage]
2024-10-04T05:18:49.7740573Z   133 |     if (!out && ++iter != kEnd)
2024-10-04T05:18:49.7740875Z       |                   ^~~~
2024-10-04T05:18:49.7741546Z ../../electron/shell/browser/ui/inspectable_web_contents.cc:133:19: note: See //docs/unsafe_buffers.md for help.
2024-10-04T05:18:49.7742134Z 2 errors generated.

Checklist

Release Notes

Notes: none

@ckerr ckerr added semver/patch backwards-compatible bug fixes target/31-x-y PR should also be added to the "31-x-y" branch. target/32-x-y PR should also be added to the "32-x-y" branch. target/33-x-y PR should also be added to the "33-x-y" branch. labels Oct 8, 2024
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Oct 8, 2024
@ckerr ckerr force-pushed the fix/fixup-43803-Wunsafe-buffer-usage-in-GetNextZoomLevel() branch from ba8dee4 to 1b298e0 Compare October 8, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-pr 🌱 PR opened in the last 24 hours semver/patch backwards-compatible bug fixes target/31-x-y PR should also be added to the "31-x-y" branch. target/32-x-y PR should also be added to the "32-x-y" branch. target/33-x-y PR should also be added to the "33-x-y" branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants