Don't crash when copying a null Rect

Bug #7158068

Change-Id: I8f5f3ee12b2c4fd1fe28212b0c6de1214f2ce5f9
This commit is contained in:
Romain Guy
2012-09-12 17:28:02 -07:00
parent c7b6ec7a7c
commit dd4b1fec4c
2 changed files with 24 additions and 12 deletions

View File

@@ -69,10 +69,14 @@ public final class Rect implements Parcelable {
* rectangle.
*/
public Rect(Rect r) {
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
if (r == null) {
left = top = right = bottom = 0;
} else {
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
}
@Override

View File

@@ -66,17 +66,25 @@ public class RectF implements Parcelable {
* rectangle.
*/
public RectF(RectF r) {
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
if (r == null) {
left = top = right = bottom = 0.0f;
} else {
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
}
public RectF(Rect r) {
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
if (r == null) {
left = top = right = bottom = 0.0f;
} else {
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
}
@Override