@@ -41,21 +41,24 @@ bool PBFHandler::read(QImage *image)
4141 }
4242
4343 QList<QByteArray> list (format ().split (' ;' ));
44- int zoom = list.size () ? list.first ().toInt () : 0 ;
45- int overzoom = (list.size () > 1 ) ? list.at (1 ).toInt () : 0 ;
46- int style = (list.size () > 2 ) ? list.at (2 ).toInt () : 0 ;
44+ unsigned zoom = list.size () ? list.first ().toUInt () : 0 ;
45+ unsigned overzoom = (list.size () > 1 ) ? list.at (1 ).toUInt () : 0 ;
46+ unsigned style = (list.size () > 2 ) ? list.at (2 ).toUInt () : 0 ;
47+
48+ if (style >= _styles.size ())
49+ style = 0 ;
4750
4851 QSize scaledSize (_scaledSize.isValid ()
4952 ? _scaledSize : QSize (TILE_SIZE, TILE_SIZE));
50- QSize size (scaledSize.width ()<<overzoom,
51- scaledSize.height ()<<overzoom);
53+ QSize size (qMin ( scaledSize.width ()<<overzoom, 4096 ) ,
54+ qMin ( scaledSize.height ()<<overzoom, 4096 ) );
5255 QPointF scale ((qreal)scaledSize.width () / TILE_SIZE,
5356 (qreal)scaledSize.height () / TILE_SIZE);
5457
5558 *image = QImage (size, QImage::Format_ARGB32_Premultiplied);
5659 Tile tile (image, zoom, scale);
5760
58- _styles.at (style < _styles. size () ? style : 0 )->render (data, tile);
61+ _styles.at (style)->render (data, tile);
5962
6063 return true ;
6164}
0 commit comments