Skip to content

Commit 68d10da

Browse files
Aleksei Voitylovgnu-andrew
Aleksei Voitylov
authored andcommitted
8343007: Enhance Buffered Image handling
Reviewed-by: yan, mbalao, andrew Backport-of: e95aaf16aa202b49892ccb05ded783114b2d8534
1 parent 93e8e20 commit 68d10da

File tree

1 file changed

+17
-1
lines changed
  • jdk/src/share/native/sun/java2d/loops

1 file changed

+17
-1
lines changed

jdk/src/share/native/sun/java2d/loops/Blit.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -68,14 +68,30 @@ Java_sun_java2d_loops_Blit_Blit
6868
return;
6969
}
7070

71+
if (width <= 0 || height <= 0) {
72+
return;
73+
}
74+
7175
srcInfo.bounds.x1 = srcx;
7276
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+
7384
srcInfo.bounds.x2 = srcx + width;
7485
srcInfo.bounds.y2 = srcy + height;
7586
dstInfo.bounds.x1 = dstx;
7687
dstInfo.bounds.y1 = dsty;
7788
dstInfo.bounds.x2 = dstx + width;
7889
dstInfo.bounds.y2 = dsty + height;
90+
if (UNSAFE_TO_SUB(srcx, dstx) ||
91+
UNSAFE_TO_SUB(srcy, dsty)) {
92+
return;
93+
}
94+
7995
srcx -= dstx;
8096
srcy -= dsty;
8197
SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);

0 commit comments

Comments
 (0)