Repository navigation
fix: --upscale 0 panic, give a clean error instead - #7
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
slimdeer file -o out.png --upscale 0 was crashing (Vec::chunks_exact need a chunk size that is not zero), not failing nice like the other bad option do. --upscale is a helper for bench/bench.py (K times enlarge), but a typo like 0 still should not panic the program. Now --upscale 0 is checked with the other --upscale checks and give a normal usage error, exit 2, same place as --target 101 or other bad value. Added to the same test that already cover these usage error.
|
@bluzername is attempting to deploy a commit to the Adastralab AI Team on Vercel. A member of the Team first needs to authorize it. |
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 free
to 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.
`slimdeer file -o out.png --upscale 0` was crashing: `Vec::chunks_exact` need a chunk size that is not zero, and `upscale()` in `cli/tools.rs` build the output width as `image.width * k`, so k=0 give width 0 and `encode_rgba` panic on `pixels.chunks_exact(0)`. Every other bad option (like `--target 101`) fail with a normal usage error, not a panic, so this one should too.
What change:
`--upscale` is a helper for `bench/bench.py`, not in `--help`, but a wrong value there still should not panic the program.
I could not run `cargo test` myself here (no code execution in my environment this run), so please double check the test pass on your side. Happy to adjust if I get something wrong.