the .data() call triggers the crash:
Uh huh, which one? There are two in your original post.

Calling data() causes a deep copy of the data block if the QByteArray is currently shared. If the data block is very large this might fail. Since it fails:
i get crashes with a certain, very specific input file.
it might help to consider what is different about that file. Is it huge?

does r change, even if i do not call resize()?
The value of r won't change unless you change it. The memory address of the QByteArray may move if you do anything non-const to the byte array. If that happens the value of r, which has not changed, becomes an invalid pointer.

I am with lanz, perhaps you should be using standard memcpy() rather than some compiler internal function (any name starting with two underscores is compiler implementation reserved and should not come from user code).