mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
GP-1 Corrected treatment of BadDataType within DataTypeManagerDB
This commit is contained in:
parent
413949b64a
commit
f250cfeac4
1 changed files with 20 additions and 3 deletions
|
@ -158,6 +158,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
private LinkedList<Long> idsToDelete = new LinkedList<>();
|
||||
private LinkedList<Pair<DataType, DataType>> typesToReplace = new LinkedList<>();
|
||||
private List<DataType> favoritesList = new ArrayList<>();
|
||||
private BadDataType myBadDataType = new BadDataType(this);
|
||||
|
||||
/**
|
||||
* Set of {@link AbstractIntegerDataType} IDs whose removal has been blocked
|
||||
|
@ -1238,6 +1239,12 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
return dataType;
|
||||
}
|
||||
|
||||
if (dataType instanceof BadDataType) {
|
||||
// Avoid adding BAD data type to the manager which
|
||||
// will appear when needed for a missing datatype
|
||||
return myBadDataType;
|
||||
}
|
||||
|
||||
if (dataType instanceof BitFieldDataType) {
|
||||
return resolveBitFieldDataType((BitFieldDataType) dataType, handler);
|
||||
}
|
||||
|
@ -1888,10 +1895,13 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
throw new IllegalArgumentException(
|
||||
"Datatype replacment with dynamic or factory type not permitted.");
|
||||
}
|
||||
if (getID(existingDt) < 0) {
|
||||
if (!contains(existingDt)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Datatype to replace is not contained in this datatype manager.");
|
||||
}
|
||||
if (existingDt instanceof BadDataType) {
|
||||
throw new IllegalArgumentException("BAD Datatype can be deleted but not replaced.");
|
||||
}
|
||||
boolean fixupName = false;
|
||||
if (!contains(replacementDt)) {
|
||||
replacementDt = replacementDt.clone(this);
|
||||
|
@ -2291,7 +2301,7 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
return DataType.DEFAULT;
|
||||
}
|
||||
if (dataTypeID == BAD_DATATYPE_ID) {
|
||||
return BadDataType.dataType;
|
||||
return myBadDataType;
|
||||
}
|
||||
return getDataType(dataTypeID, null);
|
||||
}
|
||||
|
@ -2343,6 +2353,12 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (dataType instanceof BadDataType) {
|
||||
// Cannot really replace BAD datatype which is generally not directly referenced
|
||||
deleteDataType(BAD_DATATYPE_ID);
|
||||
return true;
|
||||
}
|
||||
|
||||
long id = getID(dataType);
|
||||
if (id <= 0) { // removal of certain special types not permitted
|
||||
return false;
|
||||
|
@ -4582,7 +4598,8 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
}
|
||||
}
|
||||
|
||||
private record DedupedConflicts(int processCnt, int replaceCnt) {}
|
||||
private record DedupedConflicts(int processCnt, int replaceCnt) {
|
||||
}
|
||||
|
||||
private DedupedConflicts doDedupeConflicts(DataType dataType) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue