Test types of nodes before downcasting them
A bad cast in QSvgMarker::drawHelper lead to an endless recursion
resulting in a heap overflow. Credit to OSS-Fuzz which found this as
issue 496327371.
Amends 534d072fe9c060ca3d1b968a717513426c69c956
While fixing that, I found another, similar case and fixed it, too,
although it didn't seem to cause a crash.
Amends 29b848e9ac4e4e13c5b50116a81b1f2677196939
Pick-to: 6.11 6.8
Change-Id: Ia57491aa329fea981307a709c5a6a750125fe2c7
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>