Skip to content

Commit 05e97e8

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

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
@@ -946,6 +946,11 @@ void FontRenderer::appendRotatedMeshQuad(float x1, float y1, float u1, float v1,
946946
uint32_t FontRenderer::getRemainingCacheCapacity() {
947947
uint32_t remainingCapacity = 0;
948948
float totalPixels = 0;
949+
950+
//avoid divide by zero if the size is 0
951+
if (mCacheLines.size() == 0) {
952+
return 0;
953+
}
949954
for(uint32_t i = 0; i < mCacheLines.size(); i ++) {
950955
remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol);
951956
totalPixels += mCacheLines[i]->mMaxWidth;

0 commit comments

Comments
 (0)