InputStream from file question

Why does this code cause an exception and how should it be done right?

[code]void MainComponent::loadWave()
File file(T(“c:\wav.wav”));
if (file.exists())
InputStream *stream=file.createInputStream();
if (stream)
WavAudioFormat format;
AudioFormatReader *reader=format.createReaderFor(stream, true);
if (reader)
wave=new AudioSampleBuffer(2,(int)reader->lengthInSamples);
wave->readFromAudioReader(reader, 0, (int)reader->lengthInSamples ,0, true, true);

		deleteAndZero(stream);	// <--- EXCEPTION!!


The reader automatically deletes the stream that you give it, so just remove the line that deletes the stream and it’ll be fine.

ofcourse, sorry for this stupid question :oops: