mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* 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.trace.database.DBTrace;
|
||||
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.TraceAddressSnapRangeQuery;
|
||||
import ghidra.trace.database.thread.DBTraceThreadManager;
|
||||
|
@ -399,16 +398,16 @@ public abstract class AbstractDBTracePropertyMap<T, DR extends AbstractDBTraceAd
|
|||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
ObjectStorage objStorage =
|
||||
new ObjectStorageStreamAdapter(new ObjectOutputStream(os));
|
||||
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream objStream = new ObjectOutputStream(os)) {
|
||||
ObjectStorage objStorage = new ObjectStorageStreamAdapter(objStream);
|
||||
value.save(objStorage);
|
||||
return os.toByteArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new AssertionError(e); // For a ByteArrayOutputStream?
|
||||
}
|
||||
return os.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -50,13 +50,9 @@ public class DBTraceAddressPropertyManagerTest extends AbstractGhidraHeadlessInt
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof MySaveable)) {
|
||||
if (!(obj instanceof MySaveable that)) {
|
||||
return false;
|
||||
}
|
||||
MySaveable that = (MySaveable) obj;
|
||||
return this.i == that.i && Objects.equals(this.str, that.str);
|
||||
}
|
||||
|
||||
|
@ -117,13 +113,9 @@ public class DBTraceAddressPropertyManagerTest extends AbstractGhidraHeadlessInt
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ExtMySaveable)) {
|
||||
if (!(obj instanceof ExtMySaveable that)) {
|
||||
return false;
|
||||
}
|
||||
ExtMySaveable that = (ExtMySaveable) obj;
|
||||
return super.equals(that) && this.f == that.f;
|
||||
}
|
||||
|
||||
|
@ -335,7 +327,12 @@ public class DBTraceAddressPropertyManagerTest extends AbstractGhidraHeadlessInt
|
|||
}
|
||||
|
||||
@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;
|
||||
try (Transaction tx = tb.startTransaction()) {
|
||||
map = propertyManager.createPropertyMap("MyProp", String.class);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue