diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-01-18 07:00:49 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2011-01-18 07:12:49 (GMT) |
commit | 28951758263e1512b00ca8e2e91a0cc95d176512 (patch) | |
tree | 6b40db18de0103dc1aa2a5d86f3b543d747d5d1d /src/declarative | |
parent | de174875045c60450c8c5bff64fabf449029d86d (diff) | |
download | Qt-28951758263e1512b00ca8e2e91a0cc95d176512.zip Qt-28951758263e1512b00ca8e2e91a0cc95d176512.tar.gz Qt-28951758263e1512b00ca8e2e91a0cc95d176512.tar.bz2 |
Avoid index out of bounds array accesses
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativepositioners.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index c4b35a8..b3383ab 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -905,6 +905,9 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) c = (numVisible+(m_rows-1))/m_rows; } + if(r==0 || c==0) + return; //Nothing to do + QList<int> maxColWidth; QList<int> maxRowHeight; int childIndex =0; @@ -949,14 +952,14 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) } int widthSum = 0; - for(int j=0; j < c; j++){ + for(int j=0; j < maxColWidth.size(); j++){ if(j) widthSum += spacing(); widthSum += maxColWidth[j]; } int heightSum = 0; - for(int i=0; i < r; i++){ + for(int i=0; i < maxRowHeight.size(); i++){ if(i) heightSum += spacing(); heightSum += maxRowHeight[i]; |