SoundFile.cpp: do a NULL check before deferencing.

CID 296.
This commit is contained in:
Philippe Saint-Pierre
2012-01-02 14:26:07 -05:00
parent e9132cc34c
commit 9e4224613c
+5 -1
View File
@@ -310,7 +310,7 @@ status_t
BSoundFile::_ref_to_file(const entry_ref *ref)
{
status_t status;
BFile * file = new BFile(ref,B_READ_ONLY);
BFile * file = new BFile(ref, B_READ_ONLY);
status = file->InitCheck();
if (status != B_OK) {
fSoundFile = file;
@@ -360,6 +360,10 @@ BSoundFile::_ref_to_file(const entry_ref *ref)
if (mf.type == B_MEDIA_RAW_AUDIO) {
raw = &mf.u.raw_audio;
}
if (raw == NULL)
return B_ERROR;
fSamplingRate = (int)raw->frame_rate;
fChannelCount = raw->channel_count;
fSampleSize = raw->format & 0xf;