[qtdeclarative] Fix memory corruption bug

This is the same fix that was applied to mer-packages/qtdeclarative, commit 3cfbd9d3176cbbc95bdbe3712f4accdc1485ed55