Skip to content

Commit 345bcd8

Browse files
committed
Check before deferencing, and initialize to NULL.
Crash was observed in Release build for BRL-CAD's step-g on Ubuntu Linux without this check.
1 parent 380618f commit 345bcd8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/clstepcore/complexSupport.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,26 +173,27 @@ class SC_CORE_EXPORT EntList {
173173
// but all we need.
174174
EntList * firstNot( JoinType );
175175
EntList * nextNot( JoinType j ) {
176-
return next->firstNot( j );
176+
return ( next ) ? next->firstNot( j ) : NULL;
177177
}
178178
EntList * firstWanted( MatchType );
179179
EntList * nextWanted( MatchType mat ) {
180-
return next->firstWanted( mat );
180+
return ( next ) ? next->firstWanted( mat ) : NULL;
181181
}
182182
EntList * lastNot( JoinType );
183183
EntList * prevNot( JoinType j ) {
184-
return prev->lastNot( j );
184+
return ( prev ) ? prev->lastNot( j ) : NULL;
185185
}
186186
EntList * lastWanted( MatchType );
187187
EntList * prevWanted( MatchType mat ) {
188-
return prev->lastWanted( mat );
188+
return ( prev ) ? prev->lastWanted( mat ) : NULL;
189189
}
190190

191191
JoinType join;
192192
int multiple() {
193193
return ( join != SIMPLE );
194194
}
195-
EntList * next, *prev;
195+
EntList * next = NULL;
196+
EntList * prev = NULL;
196197

197198
protected:
198199
MatchType viable;

0 commit comments

Comments
 (0)