I'm not sure if all compilers support variable length arrays on the stack. With gcc on a Mac it works for me in a simple test program.

BUT: If your slot is not called synchronously it might be that the execution flow in the sending object left the scope of the inner if-statement when your slot gets called. At this point in time the temp array is already destroyed and you have a dangling pointer in your slot!

Why don't you pass the QByteArray as argument to the signal? That would save you the qMemCopy and Qt handles all the reference counting for you.

and of course not forget to call free(temp) after the malloc'ed memory isn't required anymore :-)

Regarding compiler support:
At least gcc does support variable length arrays on the stack as an extension to the C standard (and therefore in C++ too). With other compilers your mileage may vary. I would not depend on it, anyways. As I would avoid raw arrays of pointers wherever I can, too :-) (or put them at least into a nice object which cleans up in the destructor)