fix off-by-one thinko in GetStringUTFChars; call dlclose() in ~Library()

This commit is contained in:
Joel Dice 2007-07-04 12:15:03 -06:00
parent 25a7aae0f8
commit da844719ab
3 changed files with 13 additions and 2 deletions

View File

@ -127,7 +127,7 @@ fast-cflags = $(fast) $(cflags)
classpath-sources = $(shell find $(classpath)/java -name '*.java')
classpath-classes = $(call java-classes,$(classpath-sources),$(classpath))
input = $(bld)/classes/TestExceptions.class
input = $(bld)/classes/Hello.class
input-depends = \
$(classpath-classes) \
$(jni-library)

View File

@ -236,6 +236,12 @@ class System: public vm::System {
}
virtual void dispose() {
if (Verbose) {
fprintf(stderr, "close %p\n", p);
}
dlclose(p);
if (next_) {
next_->dispose();
}
@ -335,6 +341,10 @@ class System: public vm::System {
void* p = dlopen(buffer, RTLD_LAZY);
if (p) {
if (Verbose) {
fprintf(stderr, "open %s as %p\n", buffer, p);
}
*lib = new (vm::System::allocate(sizeof(Library)))
Library(this, p, next);
return 0;

View File

@ -2757,7 +2757,8 @@ GetStringUTFChars(JNIEnv* e, jstring s, jboolean* isCopy)
char* chars = 0;
if (LIKELY(s)) {
chars = static_cast<char*>(t->vm->system->allocate(stringLength(t, *s)));
chars = static_cast<char*>
(t->vm->system->allocate(stringLength(t, *s) + 1));
memcpy(chars,
&byteArrayBody(t, stringBytes(t, *s), stringOffset(t, *s)),