Program crashes after using GetByteArrayElements
843829Feb 3 2004 — edited Feb 3 2004 Hi,
I am passing a byte array to the native code in "C" The program crashes after i call the GetByteArrayElements.
My native code is as follows.I am trying to convert the jbytearray to (BYTE *) because one of the cryptoAPI function require BYTE * as a parameter.
BYTE *pbBuffer;
JNIEXPORT void JNICALL Java_Testapp_certificateKey
(JNIEnv * jEnv, jobject obj, jstring jcert,jbyteArray testByteArray){
jsize byteArraySize=(*jEnv)->GetArrayLength(jEnv,testByteArray);
jbyte * pMin=(jbyte *)(*jEnv)->GetByteArrayElements(jEnv,testByteArray,0);
pbBuffer= malloc(byteArraySize);
pbBuffer=(BYTE *)pMin;
dwBufferLen=strlen((char *)pbBuffer)+1;
.....
....
....
if(CryptHashData(hHash, pbBuffer, dwBufferLen,0)) {
wsprintf(msg,"The data buffer has been hashed.\n");
OutputDebugString (msg);
free(msg);
}
}