Skip to content

Commit 123f6ed

Browse files
committed
Fix Obj2yaml bug and add comment where the iterator starts uninitialized!
1 parent 807dfd3 commit 123f6ed

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

llvm/include/llvm/Object/Minidump.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ class MinidumpFile : public Binary {
140140
size_t Stride;
141141
};
142142

143+
144+
/// Class the provides an iterator over the memory64 memory ranges. Ranges
145+
/// are not validated before hand, and so any increment operation could fail.
146+
/// For this reason, the iterator in it's initial state points to a default
147+
/// initialized std::pair and should be advanced before dereferencing.
143148
class Memory64Iterator {
144149
public:
145150
static Memory64Iterator

llvm/lib/ObjectYAML/MinidumpYAML.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,11 @@ Stream::create(const Directory &StreamDesc, const object::MinidumpFile &File) {
539539
if (!ExpectedList)
540540
return ExpectedList.takeError();
541541
std::vector<Memory64ListStream::entry_type> Ranges;
542-
for (auto It = ExpectedList->begin(); It != ExpectedList->end(); ++It) {
542+
for (auto It = ExpectedList->begin(); It != ExpectedList->end();) {
543+
// Explicilty advance the iterator before dereference.
544+
++It;
543545
const auto Pair = *It;
544-
if (Err.success()) {
546+
if (!Err) {
545547
Ranges.push_back({Pair.first, Pair.second});
546548
}
547549
}

0 commit comments

Comments
 (0)