Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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);
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2004
Added on Feb 3 2004
3 comments
550 views