qt5base-lts/tests/auto/widgets/graphicsview/qgraphicsitem
Marc Mutz e2e107556d tst_QGraphicsItem: Fix UB (invalid cast/member call) in prepareGeometryChange()
Found by UBSan:

  tst_qgraphicsitem.cpp:5066:29: runtime error: downcast of address 0x2afcb006c7f0 which does not point to an object of type 'GeometryChanger'
  0x2afcb006c7f0: note: object is of type 'QGraphicsRectItem'
   00 00 00 00  d8 64 ca 98 fc 2a 00 00  40 a9 0b b0 fc 2a 00 00  75 65 29 00 00 00 00 00  35 00 00 00
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QGraphicsRectItem'
      #0 0x4c5f1c in tst_QGraphicsItem::prepareGeometryChange() tst_qgraphicsitem.cpp:5066

Fix by actually instantiating a GeometryChanger, which incidentally is
the pattern used by paint() a few lines below, too.

While at it, allocate the item on the stack (as is done in paint())
and create a local QRectF variable to avoid repeating the same magic
numbers over and over again.

Change-Id: If5a3d56511000a17703d78d7dd1f0ea072b8bc11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2016-09-22 15:25:18 +00:00
..
.gitignore Moved tests into integrationtests/ and widgets/ 2011-10-20 19:45:41 +02:00
BLACKLIST Tests: Remove tst_QGraphicsIten::sorting from the BLACKLIST file 2015-04-22 10:50:50 +00:00
qgraphicsitem.pro fix usage of wince scope 2015-06-05 10:29:10 +00:00
tst_qgraphicsitem.cpp tst_QGraphicsItem: Fix UB (invalid cast/member call) in prepareGeometryChange() 2016-09-22 15:25:18 +00:00