From fb3ec19c84c548dbf3d2f80210dfd05e92129c08 Mon Sep 17 00:00:00 2001 From: Volker Enderlein Date: Thu, 16 Jan 2025 22:12:01 +0100 Subject: [PATCH] Fix invalid access when removing callback. --- src/lists/SoCallbackList.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lists/SoCallbackList.cpp b/src/lists/SoCallbackList.cpp index 877a327cb6..9930f77e67 100644 --- a/src/lists/SoCallbackList.cpp +++ b/src/lists/SoCallbackList.cpp @@ -95,7 +95,11 @@ SoCallbackList::removeCallback(SoCallbackListCB * f, void * userdata) // of course whether it should be allowed to have the same callback // entry in the list twice...) 20050723 kyrah. while (idx != -1) { - if ((this->funclist[idx] == (void*)f) && (this->datalist[idx] == userdata)) break; + if ((this->funclist[idx] == (void*)f) && (this->datalist[idx] == userdata)) { + this->funclist.remove(idx); + this->datalist.remove(idx); + break; + } idx--; } @@ -109,9 +113,6 @@ SoCallbackList::removeCallback(SoCallbackListCB * f, void * userdata) return; } #endif // COIN_DEBUG - - this->funclist.remove(idx); - this->datalist.remove(idx); } /*!