Ticket #11111: 0001-Ticket-11111-Division-by-zero-in-TabDecorator.patch

File 0001-Ticket-11111-Division-by-zero-in-TabDecorator.patch, 1.8 KB (added by sambuddhabasu1, 10 years ago)
  • src/servers/app/decorator/TabDecorator.cpp

    From bfb4e79c681ad0b0b065551b2e21cf36be303f8f Mon Sep 17 00:00:00 2001
    From: Sambuddha Basu <sambuddhabasu1@gmail.com>
    Date: Fri, 30 Jan 2015 02:59:00 +0530
    Subject: [PATCH] Ticket 11111 - Division by zero in TabDecorator
    
    ---
     src/servers/app/decorator/TabDecorator.cpp | 13 +++++++++----
     1 file changed, 9 insertions(+), 4 deletions(-)
    
    diff --git a/src/servers/app/decorator/TabDecorator.cpp b/src/servers/app/decorator/TabDecorator.cpp
    index 0d295a0..9ac1af5 100644
    a b TabDecorator::_DoTabLayout()  
    406406void
    407407TabDecorator::_DistributeTabSize(float delta)
    408408{
    409     ASSERT(CountTabs() > 1);
     409    int32 tabCount = fTabList.CountItems();
     410    ASSERT(tabCount > 1);
    410411
    411412    float maxTabSize = 0;
    412413    float secMaxTabSize = 0;
    413414    int32 nTabsWithMaxSize = 0;
    414     for (int32 i = 0; i < fTabList.CountItems(); i++) {
     415    for (int32 i = 0; i < tabCount; i++) {
    415416        Decorator::Tab* tab = fTabList.ItemAt(i);
     417
     418        if (tab == NULL)
     419            continue;
     420
    416421        float tabWidth = tab->tabRect.Width();
    417422        if (int_equal(maxTabSize, tabWidth)) {
    418423            nTabsWithMaxSize++;
    TabDecorator::_DistributeTabSize(float delta)  
    431436    minus /= nTabsWithMaxSize;
    432437
    433438    Decorator::Tab* prevTab = NULL;
    434     for (int32 i = 0; i < fTabList.CountItems(); i++) {
     439    for (int32 i = 0; i < tabCount; i++) {
    435440        Decorator::Tab* tab = fTabList.ItemAt(i);
    436441        if (int_equal(maxTabSize, tab->tabRect.Width()))
    437442            tab->tabRect.right -= minus;
    TabDecorator::_DistributeTabSize(float delta)  
    452457    // done
    453458    prevTab->tabRect.right = floor(fFrame.right + fBorderWidth);
    454459
    455     for (int32 i = 0; i < fTabList.CountItems(); i++) {
     460    for (int32 i = 0; i < tabCount; i++) {
    456461        Decorator::Tab* tab = _TabAt(i);
    457462        tab->tabOffset = uint32(tab->tabRect.left - fLeftBorder.left);
    458463    }