mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 05:24:19 +01:00
Validate crop and video size
A video width or height of 0 triggered an assert. Fail explicitly instead: the server may actually send this size in practice (for example on cropping with small dimensions, even if the requested crop size is not 0).
This commit is contained in:
@@ -456,8 +456,14 @@ public class Options {
|
||||
}
|
||||
int width = Integer.parseInt(tokens[0]);
|
||||
int height = Integer.parseInt(tokens[1]);
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw new IllegalArgumentException("Invalid crop size: " + width + "x" + height);
|
||||
}
|
||||
int x = Integer.parseInt(tokens[2]);
|
||||
int y = Integer.parseInt(tokens[3]);
|
||||
if (x < 0 || y < 0) {
|
||||
throw new IllegalArgumentException("Invalid crop offset: " + x + ":" + y);
|
||||
}
|
||||
return new Rect(x, y, x + width, y + height);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user