diff --git a/lib/Dispatcher/DispatcherQueue.cpp b/lib/Dispatcher/DispatcherQueue.cpp index 7e635ec70a..48b4707ff1 100644 --- a/lib/Dispatcher/DispatcherQueue.cpp +++ b/lib/Dispatcher/DispatcherQueue.cpp @@ -271,7 +271,7 @@ void DispatcherQueue::beginShutdown () { } } - // no try to get rid of the remaining jobs + // now try to get rid of the remaining jobs MUTEX_LOCKER(_hazardLock); for (size_t i = 0; i < _maxSize; ++i) { @@ -302,7 +302,6 @@ void DispatcherQueue::beginShutdown () { _hazardPointer = nullptr; removeJob(job); - delete job; } } @@ -363,6 +362,15 @@ void DispatcherQueue::shutdown () { delete it; } } + + // and delete old jobs + for (size_t i = 0; i < _maxSize; ++i) { + Job* job = _jobs[i]; + + if (job != nullptr) { + delete job; + } + } } ////////////////////////////////////////////////////////////////////////////////