I'm using JNI and SWIG, both those use C strings. Both are really C packages, with only partial C++ support. The real code I'm using is largely machine generated, and I have to fix the generator.
Why is _message declared as a constant?? It is not constant. It is just a variable.
The variable messageLength is populated with a call to wcslen(). This function returns the number of characters, not the number of bytes. This is all good except to your call to SecureZeroMemory(). You are using messageLength as the second parameter. That is wrong because the second parameter expects the number of bytes, not the number of characters. The call should instead look like this:
Other than the above (and an apparently unnecessary type cast in wcscpy_s()), I don't see much of a problem. I do think that the const declaration of _message might be triggering your problem because constants are allocated by the compiler and you shouldn't have to worry about deallocating them.