Skip to content

Commit 1460c8c

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Prevent possible divide by 0 Bug #7307304" into jb-mr1-dev
2 parents 38a6424 + c37f349 commit 1460c8c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/hwui/Patch.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
134134
const float fixed = bitmapWidth - stretchSize;
135135
const float xStretch = fmaxf(right - left - fixed, 0.0f);
136136
stretchX = xStretch / xStretchTex;
137-
rescaleX = fminf(fmaxf(right - left, 0.0f) / fixed, 1.0f);
137+
rescaleX = fixed == 0.0f ? 0.0f : fminf(fmaxf(right - left, 0.0f) / fixed, 1.0f);
138138
}
139139

140140
if (yStretchCount > 0) {
@@ -146,7 +146,7 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight,
146146
const float fixed = bitmapHeight - stretchSize;
147147
const float yStretch = fmaxf(bottom - top - fixed, 0.0f);
148148
stretchY = yStretch / yStretchTex;
149-
rescaleY = fminf(fmaxf(bottom - top, 0.0f) / fixed, 1.0f);
149+
rescaleY = fixed == 0.0f ? 0.0f : fminf(fmaxf(bottom - top, 0.0f) / fixed, 1.0f);
150150
}
151151

152152
TextureVertex* vertex = mVertices;

0 commit comments

Comments
 (0)