File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ class ReflectionSectionIteratorBase
100
100
: OriginalSize(Size ), Cur(Cur), Size (Size ), Name(Name) {
101
101
if (Size != 0 ) {
102
102
auto NextRecord = this ->operator *();
103
+ if (!NextRecord) {
104
+ // NULL record pointer, don't attempt to proceed. Setting size to 0 will
105
+ // make this iterator compare equal to the end iterator.
106
+ this ->Size = 0 ;
107
+ return ;
108
+ }
103
109
auto NextSize = Self::getCurrentRecordSize (NextRecord);
104
110
if (NextSize > Size ) {
105
111
std::cerr << " !!! Reflection section too small to contain first record\n " << std::endl;
@@ -109,7 +115,9 @@ class ReflectionSectionIteratorBase
109
115
<< " , size of first record: "
110
116
<< NextSize
111
117
<< std::endl;
112
- abort ();
118
+ // Set this iterator equal to the end. This section is effectively
119
+ // empty.
120
+ this ->Size = 0 ;
113
121
}
114
122
}
115
123
}
@@ -149,14 +157,18 @@ class ReflectionSectionIteratorBase
149
157
std::cerr << std::hex << std::setw (2 ) << (int )p[i] << " " ;
150
158
}
151
159
std::cerr << std::endl;
152
- abort ();
160
+ Size = 0 ; // Set this iterator equal to the end.
153
161
}
154
162
}
155
163
156
164
return asImpl ();
157
165
}
158
166
159
167
bool operator ==(const Self &other) const {
168
+ // Size = 0 means we're at the end even if Cur doesn't match. This allows
169
+ // iterators that encounter an incorrect size to safely end iteration.
170
+ if (Size == 0 && other.Size == 0 )
171
+ return true ;
160
172
return Cur == other.Cur && Size == other.Size ;
161
173
}
162
174
You can’t perform that action at this time.
0 commit comments