mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-5121: Fix unflushed buffer in Saveable TracePropertyMap
This commit is contained in:
parent
26b7540681
commit
2f86a780f0
2 changed files with 17 additions and 21 deletions
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -28,7 +28,6 @@ import ghidra.program.model.address.*;
|
||||||
import ghidra.program.model.lang.Language;
|
import ghidra.program.model.lang.Language;
|
||||||
import ghidra.trace.database.DBTrace;
|
import ghidra.trace.database.DBTrace;
|
||||||
import ghidra.trace.database.DBTraceUtils;
|
import ghidra.trace.database.DBTraceUtils;
|
||||||
import ghidra.trace.database.map.AbstractDBTracePropertyMap.DBTraceSaveablePropertyMapEntry;
|
|
||||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.AbstractDBTraceAddressSnapRangePropertyMapData;
|
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.AbstractDBTraceAddressSnapRangePropertyMapData;
|
||||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.TraceAddressSnapRangeQuery;
|
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.TraceAddressSnapRangeQuery;
|
||||||
import ghidra.trace.database.thread.DBTraceThreadManager;
|
import ghidra.trace.database.thread.DBTraceThreadManager;
|
||||||
|
@ -399,16 +398,16 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
ObjectStorage objStorage =
|
try (ObjectOutputStream objStream = new ObjectOutputStream(os)) {
|
||||||
new ObjectStorageStreamAdapter(new ObjectOutputStream(os));
|
ObjectStorage objStorage = new ObjectStorageStreamAdapter(objStream);
|
||||||
value.save(objStorage);
|
value.save(objStorage);
|
||||||
return os.toByteArray();
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new AssertionError(e); // For a ByteArrayOutputStream?
|
throw new AssertionError(e); // For a ByteArrayOutputStream?
|
||||||
}
|
}
|
||||||
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -50,13 +50,9 @@ public class DBTraceAddressPropertyManagerTest extends AbstractGhidraHeadlessInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == this) {
|
if (!(obj instanceof MySaveable that)) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(obj instanceof MySaveable)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MySaveable that = (MySaveable) obj;
|
|
||||||
return this.i == that.i && Objects.equals(this.str, that.str);
|
return this.i == that.i && Objects.equals(this.str, that.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,13 +113,9 @@ public class DBTraceAddressPropertyManagerTest extends AbstractGhidraHeadlessInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == this) {
|
if (!(obj instanceof ExtMySaveable that)) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(obj instanceof ExtMySaveable)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ExtMySaveable that = (ExtMySaveable) obj;
|
|
||||||
return super.equals(that) && this.f == that.f;
|
return super.equals(that) && this.f == that.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +327,12 @@ public class DBTraceAddressPropertyManagerTest extends AbstractGhidraHeadlessInt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStringMapAtNoAdress() throws Exception {
|
public void testExtSaveableMap() throws Exception {
|
||||||
|
doTestMap(ExtMySaveable.class, new ExtMySaveable(6, "MyString", 0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStringMapAtNoAddress() throws Exception {
|
||||||
TracePropertyMap<String> map;
|
TracePropertyMap<String> map;
|
||||||
try (Transaction tx = tb.startTransaction()) {
|
try (Transaction tx = tb.startTransaction()) {
|
||||||
map = propertyManager.createPropertyMap("MyProp", String.class);
|
map = propertyManager.createPropertyMap("MyProp", String.class);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue