diff options
| author | Mason Reed <mason@vector35.com> | 2025-02-11 13:57:47 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-02-11 22:13:56 -0500 |
| commit | b546d0c8d8957064424f37f1cae7bc5fc3695f4a (patch) | |
| tree | 809bad573aa08ba6611697cc9c2d4d4464b3c747 /highlevelil.cpp | |
| parent | 127ab740841f6938e359650c742314a7f1185904 (diff) | |
Fix partial initialization of `DisassemblyTextLine`
The usage of `DisassemblyTextLine` in the FFI was unsound, we would forget to initialize some fields causing a myriad of issues where round-tripping through the FFI was losing information.
Diffstat (limited to 'highlevelil.cpp')
| -rw-r--r-- | highlevelil.cpp | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/highlevelil.cpp b/highlevelil.cpp index 121dc406..23587fca 100644 --- a/highlevelil.cpp +++ b/highlevelil.cpp @@ -19,6 +19,7 @@ // IN THE SOFTWARE. #include "binaryninjaapi.h" +#include "ffi.h" #include "highlevelilinstruction.h" using namespace BinaryNinja; @@ -485,19 +486,7 @@ vector<DisassemblyTextLine> HighLevelILFunction::GetExprText(ExprId expr, bool a BNDisassemblyTextLine* lines = BNGetHighLevelILExprText(m_object, expr, asFullAst, &count, settings ? settings->GetObject() : nullptr); - vector<DisassemblyTextLine> result; - result.reserve(count); - for (size_t i = 0; i < count; i++) - { - DisassemblyTextLine line; - line.addr = lines[i].addr; - line.instrIndex = lines[i].instrIndex; - line.highlight = lines[i].highlight; - line.tokens = InstructionTextToken::ConvertInstructionTextTokenList(lines[i].tokens, lines[i].count); - line.tags = Tag::ConvertTagList(lines[i].tags, lines[i].tagCount); - result.push_back(line); - } - + vector<DisassemblyTextLine> result = ParseAPIObjectList<DisassemblyTextLine>(lines, count); BNFreeDisassemblyTextLines(lines, count); return result; } @@ -871,19 +860,7 @@ vector<DisassemblyTextLine> HighLevelILTokenEmitter::GetLines() const size_t count = 0; BNDisassemblyTextLine* lines = BNHighLevelILTokenEmitterGetLines(m_object, &count); - vector<DisassemblyTextLine> result; - result.reserve(count); - for (size_t i = 0; i < count; i++) - { - DisassemblyTextLine line; - line.addr = lines[i].addr; - line.instrIndex = lines[i].instrIndex; - line.highlight = lines[i].highlight; - line.tokens = InstructionTextToken::ConvertInstructionTextTokenList(lines[i].tokens, lines[i].count); - line.tags = Tag::ConvertTagList(lines[i].tags, lines[i].tagCount); - result.push_back(line); - } - + vector<DisassemblyTextLine> result = ParseAPIObjectList<DisassemblyTextLine>(lines, count); BNFreeDisassemblyTextLines(lines, count); return result; } |
