- Notifications
You must be signed in to change notification settings - Fork11.6k
ui: fix crash of live cam on arch-linux#1602
Open
binarytrails wants to merge 2 commits intohacksider:mainfrom
Open
ui: fix crash of live cam on arch-linux#1602binarytrails wants to merge 2 commits intohacksider:mainfrom
binarytrails wants to merge 2 commits intohacksider:mainfrom
Conversation
Ensure the dimensions are valid before attempting the resize operation
Contributor
sourcery-aibot commentedDec 7, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds robust validation of target and computed dimensions in fit_image_to_size to prevent invalid resize operations (e.g., zero or negative sizes) that can crash the live cam on some systems. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess yourdashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:##Individual Comments###Comment 1<location>`modules/ui.py:769` </location><code_context> def fit_image_to_size(image, width: int, height: int): if width is None and height is None: return image+ if not isinstance(width, int) or not isinstance(height, int) or width <= 0 or height <= 0:+ return image h, w, _ = image.shape</code_context><issue_to_address>**suggestion:** The strict`int` type check may reject valid numeric types (e.g., NumPy integer scalars).This check will be`False` for types like`numpy.int32`, so calls with common integer-like dimensions will unexpectedly return the original image. Consider using`numbers.Integral` (or a similar numeric protocol) instead of`int`, or relying on the`<= 0` guard and handling any type errors at the resize call, so valid integer-like widths/heights are accepted.Suggested implementation:```pythondeffit_image_to_size(image,width:int,height:int):if widthisNoneand heightisNone:return imageifnotisinstance(width, numbers.Integral)ornotisinstance(height, numbers.Integral)or width<=0or height<=0:return image```Add`import numbers` (or`from numbers import Integral` and adjust the checks accordingly) near the top of`modules/ui.py`, alongside the other imports:- Option 1:-`import numbers`- keep`isinstance(width, numbers.Integral)` /`isinstance(height, numbers.Integral)`- Option 2:-`from numbers import Integral`- change the checks to`isinstance(width, Integral)` /`isinstance(height, Integral)`</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Uh oh!
There was an error while loading.Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Ensure the dimensions are valid before attempting the resize operation
Summary by Sourcery
Bug Fixes: