respect string offset and length when printing exception message

This commit is contained in:
Joel Dice 2007-06-29 20:45:45 -06:00
parent b33f0c311d
commit 051e3bc7a8

View File

@ -3973,8 +3973,13 @@ run(Thread* t)
(t, className(t, objectClass(exception)), 0));
if (throwableMessage(t, exception)) {
fprintf(stderr, ": %s\n", &byteArrayBody
(t, stringBytes(t, throwableMessage(t, exception)), 0));
object m = throwableMessage(t, exception);
char message[stringLength(t, m) + 1];
memcpy(message,
&byteArrayBody(t, stringBytes(t, m), stringOffset(t, m)),
stringLength(t, m));
message[stringLength(t, m)] = 0;
fprintf(stderr, ": %s\n", message);
} else {
fprintf(stderr, "\n");
}