Skip to content

Commit b603981

Browse files
Jean-Baptiste QueruAndroid Git Automerger
authored andcommitted
am 05e97e8: am 0be33f2: Merge "Add shortcut to avoid potential divide by zero in some case"
* commit '05e97e81a5fa2c9cab4cdda15aa2d036243a0c0e': Add shortcut to avoid potential divide by zero in some case
2 parents a56d9ce + 05e97e8 commit b603981

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

libs/hwui/FontRenderer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,11 @@ void FontRenderer::appendRotatedMeshQuad(float x1, float y1, float u1, float v1,
963963
uint32_t FontRenderer::getRemainingCacheCapacity() {
964964
uint32_t remainingCapacity = 0;
965965
float totalPixels = 0;
966+
967+
//avoid divide by zero if the size is 0
968+
if (mCacheLines.size() == 0) {
969+
return 0;
970+
}
966971
for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
967972
remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol);
968973
totalPixels += mCacheLines[i]->mMaxWidth;

0 commit comments

Comments
 (0)