Skip to content

Commit 0be33f2

Browse files
Jean-Baptiste Queruandroid code review
authored andcommitted
Merge "Add shortcut to avoid potential divide by zero in some case"
2 parents 9ab84c2 + 0412cfc commit 0be33f2

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)