Skip to content

Commit 5f9b93c

Browse files
committed
Fix for renaming stack variable causing invalid storage error
1 parent 37298e9 commit 5f9b93c

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/HighFunctionDBUtil.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,9 @@ private static boolean isValidUniqueVariable(HighFunction highFunction, Variable
300300
* database which conflict with this variable and return
301301
* one of them for re-use. The returned variable still
302302
* exists within the function at the same first-use-offset.
303-
* @throws InvalidInputException
304-
* @returns variable with conflicting storage or null, all
305-
* aspects of variable returned should be reset (i.e., name, datatype and storage)
303+
* @returns existing variable with identical storage and first-use offset or null
306304
*/
307-
private static Variable clearConflictingLocalVariables(HighLocal local)
308-
throws InvalidInputException {
305+
private static Variable clearConflictingLocalVariables(HighLocal local) {
309306

310307
if (local instanceof HighParam) {
311308
throw new IllegalArgumentException();
@@ -344,10 +341,7 @@ private static Variable clearConflictingLocalVariables(HighLocal local)
344341
VariableStorage otherStorage = otherVar.getVariableStorage();
345342

346343
if (otherStorage.intersects(storage)) {
347-
if (matchingVariable == null || otherStorage.equals(storage)) {
348-
if (matchingVariable != null) {
349-
func.removeVariable(matchingVariable);
350-
}
344+
if (matchingVariable == null && otherStorage.equals(storage)) {
351345
matchingVariable = otherVar;
352346
continue;
353347
}
@@ -460,7 +454,7 @@ else if (variable instanceof HighLocal) {
460454
Variable var = clearConflictingLocalVariables(local);
461455
if (dataType == null) {
462456
if (var != null) {
463-
dataType = var.getDataType(); // Use preexisting datatype
457+
dataType = var.getDataType(); // Use preexisting datatype if it fits in desired storage
464458
}
465459
else {
466460
dataType = Undefined.getUndefinedDataType(variable.getSize());

0 commit comments

Comments
 (0)