mirror of
https://github.com/corda/corda.git
synced 2024-12-28 00:38:55 +00:00
fix off-by-one thinko in GetStringUTFChars; call dlclose() in ~Library()
This commit is contained in:
parent
25a7aae0f8
commit
da844719ab
2
makefile
2
makefile
@ -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)
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -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;
|
||||
|
@ -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)),
|
||||
|
Loading…
Reference in New Issue
Block a user