MediaConverter: Move a NULL check

To avoid a NULL dereference, moving a NULL check earlier.

CID 5955.
This commit is contained in:
Philippe Saint-Pierre
2012-01-02 23:27:59 -05:00
parent 7cd8f5f9b9
commit 82556487af
+3 -4
View File
@@ -41,11 +41,13 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
for (int32 i = 0; i < tracks && (!audioDone || !videoDone); i++) { for (int32 i = 0; i < tracks && (!audioDone || !videoDone); i++) {
track = file->TrackAt(i); track = file->TrackAt(i);
if (track == NULL)
return B_ERROR;
ret = track->InitCheck(); ret = track->InitCheck();
if (ret != B_OK) if (ret != B_OK)
return ret; return ret;
if (track != NULL) {
ret = track->EncodedFormat(&format); ret = track->EncodedFormat(&format);
if (ret != B_OK) if (ret != B_OK)
return ret; return ret;
@@ -84,7 +86,6 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
ret = track->DecodedFormat(&format); ret = track->DecodedFormat(&format);
if (ret != B_OK) if (ret != B_OK)
return ret; return ret;
media_raw_audio_format *raf = &(format.u.raw_audio); media_raw_audio_format *raf = &(format.u.raw_audio);
char bytesPerSample = (char)(raf->format & 0xf); char bytesPerSample = (char)(raf->format & 0xf);
@@ -106,7 +107,6 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
audio.format << codecInfo.pretty_name; audio.format << codecInfo.pretty_name;
audioDuration = track->Duration(); audioDuration = track->Duration();
audioFrames = track->CountFrames(); audioFrames = track->CountFrames();
BString channels; BString channels;
if (raf->channel_count == 1) { if (raf->channel_count == 1) {
snprintf(channels.LockBuffer(64), 64, snprintf(channels.LockBuffer(64), 64,
@@ -130,7 +130,6 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
if (ret != B_OK) if (ret != B_OK)
return ret; return ret;
} }
}
useconds = MAX(audioDuration, videoDuration); useconds = MAX(audioDuration, videoDuration);
duration << (int32)(useconds / 1000000) duration << (int32)(useconds / 1000000)