mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
Merge pull request #224 from bigfatbrowncat/avian-pack
Properties don't work in some cases
This commit is contained in:
commit
f7614bf8a7
@ -1263,7 +1263,7 @@ class Machine {
|
|||||||
Thread* exclusive;
|
Thread* exclusive;
|
||||||
Thread* finalizeThread;
|
Thread* finalizeThread;
|
||||||
Reference* jniReferences;
|
Reference* jniReferences;
|
||||||
const char** properties;
|
char** properties;
|
||||||
unsigned propertyCount;
|
unsigned propertyCount;
|
||||||
const char** arguments;
|
const char** arguments;
|
||||||
unsigned argumentCount;
|
unsigned argumentCount;
|
||||||
|
@ -3944,10 +3944,10 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned cpl = strlen(classpath);
|
unsigned cpl = strlen(classpath);
|
||||||
RUNTIME_ARRAY(char, classpathProperty, cpl + sizeof(CLASSPATH_PROPERTY) + 1);
|
RUNTIME_ARRAY(char, classpathProperty, cpl + strlen(CLASSPATH_PROPERTY) + 2);
|
||||||
if (addClasspathProperty) {
|
if (addClasspathProperty) {
|
||||||
char* p = RUNTIME_ARRAY_BODY(classpathProperty);
|
char* p = RUNTIME_ARRAY_BODY(classpathProperty);
|
||||||
local::append(&p, CLASSPATH_PROPERTY, sizeof(CLASSPATH_PROPERTY), '=');
|
local::append(&p, CLASSPATH_PROPERTY, strlen(CLASSPATH_PROPERTY), '=');
|
||||||
local::append(&p, classpath, cpl, 0);
|
local::append(&p, classpath, cpl, 0);
|
||||||
*(propertyPointer++) = RUNTIME_ARRAY_BODY(classpathProperty);
|
*(propertyPointer++) = RUNTIME_ARRAY_BODY(classpathProperty);
|
||||||
}
|
}
|
||||||
@ -3962,6 +3962,8 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
|
|||||||
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions,
|
(s, h, bf, af, p, c, properties, propertyCount, arguments, a->nOptions,
|
||||||
stackLimit);
|
stackLimit);
|
||||||
|
|
||||||
|
h->free(properties, sizeof(const char*) * propertyCount);
|
||||||
|
|
||||||
*t = p->makeThread(*m, 0, 0);
|
*t = p->makeThread(*m, 0, 0);
|
||||||
|
|
||||||
enter(*t, Thread::ActiveState);
|
enter(*t, Thread::ActiveState);
|
||||||
|
@ -3119,7 +3119,6 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
|||||||
exclusive(0),
|
exclusive(0),
|
||||||
finalizeThread(0),
|
finalizeThread(0),
|
||||||
jniReferences(0),
|
jniReferences(0),
|
||||||
properties(properties),
|
|
||||||
propertyCount(propertyCount),
|
propertyCount(propertyCount),
|
||||||
arguments(arguments),
|
arguments(arguments),
|
||||||
argumentCount(argumentCount),
|
argumentCount(argumentCount),
|
||||||
@ -3156,6 +3155,15 @@ Machine::Machine(System* system, Heap* heap, Finder* bootFinder,
|
|||||||
|
|
||||||
populateJNITables(&javaVMVTable, &jniEnvVTable);
|
populateJNITables(&javaVMVTable, &jniEnvVTable);
|
||||||
|
|
||||||
|
// Copying the properties memory (to avoid memory crashes)
|
||||||
|
this->properties = (char**)heap->allocate(sizeof(char*) * propertyCount);
|
||||||
|
for (unsigned int i = 0; i < propertyCount; i++)
|
||||||
|
{
|
||||||
|
size_t length = strlen(properties[i]) + 1; // +1 for null-terminating char
|
||||||
|
this->properties[i] = (char*)heap->allocate(sizeof(char) * length);
|
||||||
|
memcpy(this->properties[i], properties[i], length);
|
||||||
|
}
|
||||||
|
|
||||||
const char* bootstrapProperty = findProperty(this, BOOTSTRAP_PROPERTY);
|
const char* bootstrapProperty = findProperty(this, BOOTSTRAP_PROPERTY);
|
||||||
const char* bootstrapPropertyDup = bootstrapProperty ? strdup(bootstrapProperty) : 0;
|
const char* bootstrapPropertyDup = bootstrapProperty ? strdup(bootstrapProperty) : 0;
|
||||||
const char* bootstrapPropertyEnd = bootstrapPropertyDup + (bootstrapPropertyDup ? strlen(bootstrapPropertyDup) : 0);
|
const char* bootstrapPropertyEnd = bootstrapPropertyDup + (bootstrapPropertyDup ? strlen(bootstrapPropertyDup) : 0);
|
||||||
@ -3222,6 +3230,10 @@ Machine::dispose()
|
|||||||
|
|
||||||
heap->free(arguments, sizeof(const char*) * argumentCount);
|
heap->free(arguments, sizeof(const char*) * argumentCount);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < propertyCount; i++)
|
||||||
|
{
|
||||||
|
heap->free(properties[i], sizeof(char) * (strlen(properties[i]) + 1));
|
||||||
|
}
|
||||||
heap->free(properties, sizeof(const char*) * propertyCount);
|
heap->free(properties, sizeof(const char*) * propertyCount);
|
||||||
|
|
||||||
static_cast<HeapClient*>(heapClient)->dispose();
|
static_cast<HeapClient*>(heapClient)->dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user