mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-26 00:29:27 +00:00
Avoid a crash in nativeStateExtractDiskPaths()
This commit is contained in:
parent
c731c2a310
commit
2a263e2418
|
@ -551,18 +551,21 @@ jstring Java_org_deadc0de_apple2ix_Apple2Activity_nativeStateExtractDiskPaths(JN
|
||||||
LOG(": (%s)", path);
|
LOG(": (%s)", path);
|
||||||
|
|
||||||
JSON_ref jsonData;
|
JSON_ref jsonData;
|
||||||
|
bool ret = json_createFromString("{}", &jsonData);
|
||||||
|
assert(ret >= 0 && "should be able to create JSON");
|
||||||
|
|
||||||
if (!emulator_stateExtractDiskPaths(path, &jsonData)) {
|
if (!emulator_stateExtractDiskPaths(path, &jsonData)) {
|
||||||
LOG("OOPS, could not extract disk paths from emulator state file");
|
LOG("OOPS, could not extract disk paths from emulator state file");
|
||||||
}
|
}
|
||||||
|
|
||||||
(*env)->ReleaseStringUTFChars(env, jPath, path);
|
|
||||||
|
|
||||||
char *jsonString = ((JSON_s *)jsonData)->jsonString;
|
char *jsonString = ((JSON_s *)jsonData)->jsonString;
|
||||||
|
|
||||||
jstring jstr = (*env)->NewStringUTF(env, jsonString);
|
jstring jstr = (*env)->NewStringUTF(env, jsonString);
|
||||||
|
|
||||||
json_destroy(&jsonData);
|
json_destroy(&jsonData);
|
||||||
|
|
||||||
|
(*env)->ReleaseStringUTFChars(env, jPath, path);
|
||||||
|
|
||||||
return jstr;
|
return jstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1126,11 +1126,6 @@ static bool _disk6_loadState(StateHelper_s *helper, JSON_ref *json) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (json != NULL) {
|
if (json != NULL) {
|
||||||
if (!json_createFromString("{}", json)) {
|
|
||||||
LOG("OOPS, could not create JSON!");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
json_mapSetStringValue(*json, "diskA", "");
|
json_mapSetStringValue(*json, "diskA", "");
|
||||||
json_mapSetStringValue(*json, "diskB", "");
|
json_mapSetStringValue(*json, "diskB", "");
|
||||||
json_mapSetBoolValue(*json, "readOnlyA", "true");
|
json_mapSetBoolValue(*json, "readOnlyA", "true");
|
||||||
|
|
|
@ -288,6 +288,7 @@ bool emulator_stateExtractDiskPaths(const char * const path, JSON_ref *json) {
|
||||||
do {
|
do {
|
||||||
TEMP_FAILURE_RETRY(fd = open(path, O_RDONLY));
|
TEMP_FAILURE_RETRY(fd = open(path, O_RDONLY));
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
ERRLOG("OOPS, cannot open path %s", path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(fd != 0 && "crazy platform");
|
assert(fd != 0 && "crazy platform");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user