[qtdeclarative] Fix memory corruption bug

This is the same fix that was applied to mer-packages/qtdeclarative
https://github.com/mer-packages/qtdeclarative/commit/3cfbd9d3176cbbc95bdbe3712f4accdc1485ed55