Skip to content

Commit

Permalink
BinExport: Ghidra: Fix off-by-one string and comment index
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 625375619
Change-Id: Idaff3b765c0e58d87308ccdb184814f0ba02d387
  • Loading branch information
mike-hunhoff authored and copybara-github committed Apr 16, 2024
1 parent 0da32c1 commit 92a09df
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ private void buildStrings(Map<Long, Integer> instructionIndices) {
}

builder.addStringTable(str);
int strIdx = builder.getStringTableCount();
int strIdx = builder.getStringTableCount() - 1;

for (Reference refTo : data.getReferenceIteratorTo()) {
Instruction insn = listing.getInstructionAt(refTo.getFromAddress());
Expand Down Expand Up @@ -550,15 +550,15 @@ private void buildComments(Map<Long, Integer> instructionIndices) {
continue;
}
builder.addStringTable(str);
int strIdx = builder.getStringTableCount();
int strIdx = builder.getStringTableCount() - 1;

builder
.addCommentBuilder()
.setInstructionIndex(instrIdx)
.setStringTableIndex(strIdx)
.setRepeatable(false)
.setType(BinExport2.Comment.Type.DEFAULT);
int commentIdx = builder.getCommentCount();
int commentIdx = builder.getCommentCount() - 1;

builder.getInstructionBuilder(instrIdx).addCommentIndex(commentIdx);
}
Expand Down

0 comments on commit 92a09df

Please sign in to comment.