Add(Audio|Video)Track: fix memory leak on failure

quiets a static analysis warning

Change-Id: Iaa6909e94deae81ace3e65f37ab746d72031620f
This commit is contained in:
James Zern 2017-05-01 15:17:30 -07:00
parent a65b9e0287
commit b0cea9ce24

View File

@ -3361,7 +3361,10 @@ uint64_t Segment::AddVideoTrack(int32_t width, int32_t height, int32_t number) {
track->set_width(width);
track->set_height(height);
tracks_.AddTrack(track, number);
if (!tracks_.AddTrack(track, number)) {
delete track;
return 0;
}
has_video_ = true;
return track->number();
@ -3401,7 +3404,10 @@ uint64_t Segment::AddAudioTrack(int32_t sample_rate, int32_t channels,
track->set_sample_rate(sample_rate);
track->set_channels(channels);
tracks_.AddTrack(track, number);
if (!tracks_.AddTrack(track, number)) {
delete track;
return 0;
}
return track->number();
}