@@ -49,24 +49,35 @@ namespace ze_lib
4949 if (loader) {
5050 FREE_DRIVER_LIBRARY ( loader );
5151 }
52- ze_lib::stabilityCheckThreadStarted->store (-1 );
52+ if (ze_lib::stabilityCheckThreadStarted)
53+ ze_lib::stabilityCheckThreadStarted->store (-1 );
5354 try {
54- if (stabilityThread->joinable ()) {
55+ if (stabilityThread && stabilityThread ->joinable ()) {
5556 stabilityThread->join ();
5657 }
5758 } catch (...) {
5859 // Ignore any exceptions from thread join
5960 }
60- delete stabilityThread;
61- stabilityThread = nullptr ;
62- delete stabilityMutex;
63- stabilityMutex = nullptr ;
64- delete stabilityPromiseResult;
65- stabilityPromiseResult = nullptr ;
66- delete resultFutureResult;
67- resultFutureResult = nullptr ;
68- delete stabilityCheckThreadStarted;
69- stabilityCheckThreadStarted = nullptr ;
61+ if (stabilityThread) {
62+ delete stabilityThread;
63+ stabilityThread = nullptr ;
64+ }
65+ if (stabilityMutex) {
66+ delete stabilityMutex;
67+ stabilityMutex = nullptr ;
68+ }
69+ if (stabilityPromiseResult) {
70+ delete stabilityPromiseResult;
71+ stabilityPromiseResult = nullptr ;
72+ }
73+ if (resultFutureResult) {
74+ delete resultFutureResult;
75+ resultFutureResult = nullptr ;
76+ }
77+ if (stabilityCheckThreadStarted) {
78+ delete stabilityCheckThreadStarted;
79+ stabilityCheckThreadStarted = nullptr ;
80+ }
7081#endif
7182 ze_lib::destruction = true ;
7283 };
0 commit comments