I’ve just done an audit of my own code in relation to potentially “dangerous” calls to std::unique_ptr<T>::release()
and noticed that there are few places in the JUCE code, where release()
seems to be called with the intention of deleting a unique_ptr
when in fact it doesn’t do that. Rather it simply releases ownership
not memory.
For example in juce_WavAudioFormat.cpp::1757:
if (writer != nullptr)
{
outStream.release();
Also in juce_*_Windowing.cpp we have code like:
std::unique_ptr<WindowsMessageBox> mb (new WindowsMessageBox (iconType, title, message, associatedComponent,
MB_OKCANCEL, callback, callback != nullptr));
if (callback == nullptr)
return mb->getResult() != 0;
mb.release();
And juce_AlertWindow.cpp:597
alertBox->enterModalState (true, callback, true);
alertBox.release();
There may be other instances.
NOTE: this is on the latest JUCE6 branch
Jamie