mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 12:49:35 +08:00
java: Make SVWindow more robust (fix three CID issues)
1386093 Division or modulo by zero 1386096 Division or modulo by float zero 1386101 Division or modulo by float zero A division by zero would have occurred if both sizeX and canvasSizeX or sizeY and canvasSizeY were 0. Catch also negative sizes which don't raise a division by zero exception but which are also invalid. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
64e2efffc7
commit
63d5709958
@ -204,10 +204,20 @@ public class SVWindow extends JFrame {
|
||||
super(name);
|
||||
|
||||
// Provide defaults for sizes.
|
||||
if (sizeX == 0) sizeX = canvasSizeX;
|
||||
if (sizeY == 0) sizeY = canvasSizeY;
|
||||
if (canvasSizeX == 0) canvasSizeX = sizeX;
|
||||
if (canvasSizeY == 0) canvasSizeY = sizeY;
|
||||
if (sizeX <= 0) sizeX = canvasSizeX;
|
||||
if (sizeY <= 0) sizeY = canvasSizeY;
|
||||
if (canvasSizeX <= 0) canvasSizeX = sizeX;
|
||||
if (canvasSizeY <= 0) canvasSizeY = sizeY;
|
||||
|
||||
// Avoid later division by zero.
|
||||
if (sizeX <= 0) {
|
||||
sizeX = 1;
|
||||
canvasSizeX = sizeX;
|
||||
}
|
||||
if (sizeY <= 0) {
|
||||
sizeY = 1;
|
||||
canvasSizeY = sizeY;
|
||||
}
|
||||
|
||||
// Initialize variables
|
||||
nrWindows++;
|
||||
|
Loading…
Reference in New Issue
Block a user