fix QByteArray allocation.

(Cherry picked from commit 7b80a949e828af47ede0edfab77c9110b3df6d5a)