Don't assume that Java byte arrays are null terminated.

This commit is contained in:
Sam Ruby 2000-07-22 12:40:49 +00:00
parent a5a9a4928b
commit 313ca6b5e8
2 changed files with 4 additions and 2 deletions

View file

@ -653,7 +653,8 @@ JNIEXPORT void JNICALL Java_net_php_reflect_setResultFromString
presult->type=IS_STRING;
presult->value.str.len=(*jenv)->GetArrayLength(jenv, jvalue);
presult->value.str.val=emalloc(presult->value.str.len+1);
strcpy(presult->value.str.val, value);
memcpy(presult->value.str.val, value, presult->value.str.len);
presult->value.str.val[presult->value.str.len]=0;
if (isCopy) (*jenv)->ReleaseByteArrayElements(jenv, jvalue, value, 0);
}