|
1 | 1 | /* |
2 | | - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -68,14 +68,30 @@ Java_sun_java2d_loops_Blit_Blit |
68 | 68 | return; |
69 | 69 | } |
70 | 70 |
|
| 71 | + if (width <= 0 || height <= 0) { |
| 72 | + return; |
| 73 | + } |
| 74 | + |
71 | 75 | srcInfo.bounds.x1 = srcx; |
72 | 76 | srcInfo.bounds.y1 = srcy; |
| 77 | + if (UNSAFE_TO_ADD(srcx, width) || |
| 78 | + UNSAFE_TO_ADD(srcy, height) || |
| 79 | + UNSAFE_TO_ADD(dstx, width) || |
| 80 | + UNSAFE_TO_ADD(dsty, height)) { |
| 81 | + return; |
| 82 | + } |
| 83 | + |
73 | 84 | srcInfo.bounds.x2 = srcx + width; |
74 | 85 | srcInfo.bounds.y2 = srcy + height; |
75 | 86 | dstInfo.bounds.x1 = dstx; |
76 | 87 | dstInfo.bounds.y1 = dsty; |
77 | 88 | dstInfo.bounds.x2 = dstx + width; |
78 | 89 | dstInfo.bounds.y2 = dsty + height; |
| 90 | + if (UNSAFE_TO_SUB(srcx, dstx) || |
| 91 | + UNSAFE_TO_SUB(srcy, dsty)) { |
| 92 | + return; |
| 93 | + } |
| 94 | + |
79 | 95 | srcx -= dstx; |
80 | 96 | srcy -= dsty; |
81 | 97 | SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds); |
|
0 commit comments