fix thinko in NewString() and make NewStringUTF() more robust

This commit is contained in:
Joel Dice 2007-10-26 18:04:20 -06:00
parent fcc50f4da6
commit 85012ba5b0

View File

@ -109,8 +109,8 @@ NewString(Thread* t, const jchar* chars, jsize size)
object a = 0;
if (size) {
object a = makeCharArray(t, size, false);
memcpy(&charArrayBody(t, a, 0), chars, size);
a = makeCharArray(t, size, false);
memcpy(&charArrayBody(t, a, 0), chars, size * sizeof(jchar));
}
object s = makeString(t, a, 0, size, 0);
@ -122,7 +122,15 @@ NewStringUTF(Thread* t, const char* chars)
{
ENTER(t, Thread::ActiveState);
return makeLocalReference(t, makeString(t, "%s", chars));
object a = 0;
unsigned size = strlen(chars);
if (size) {
a = makeByteArray(t, size, false);
memcpy(&byteArrayBody(t, a, 0), chars, size);
}
object s = makeString(t, a, 0, size, 0);
return makeLocalReference(t, s);
}
jclass JNICALL