Skip to content

Commit 905021d

Browse files
authoredJan 16, 2025··
Merge pull request #545 from coin3d/issue544
Fix invalid access when removing callback.
2 parents 67a4b06 + fb3ec19 commit 905021d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎src/lists/SoCallbackList.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ SoCallbackList::removeCallback(SoCallbackListCB * f, void * userdata)
9595
// of course whether it should be allowed to have the same callback
9696
// entry in the list twice...) 20050723 kyrah.
9797
while (idx != -1) {
98-
if ((this->funclist[idx] == (void*)f) && (this->datalist[idx] == userdata)) break;
98+
if ((this->funclist[idx] == (void*)f) && (this->datalist[idx] == userdata)) {
99+
this->funclist.remove(idx);
100+
this->datalist.remove(idx);
101+
break;
102+
}
99103
idx--;
100104
}
101105

@@ -109,9 +113,6 @@ SoCallbackList::removeCallback(SoCallbackListCB * f, void * userdata)
109113
return;
110114
}
111115
#endif // COIN_DEBUG
112-
113-
this->funclist.remove(idx);
114-
this->datalist.remove(idx);
115116
}
116117

117118
/*!

0 commit comments

Comments
 (0)