On init failure, let's just free it, so next time it will be recreated from
start.
Also fixes Coverity CID 1241515.
Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Marton Balint <cus@passwd.hu>
... | ... |
@@ -2419,6 +2419,7 @@ static int audio_decode_frame(VideoState *is) |
2419 | 2419 |
"Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n", |
2420 | 2420 |
is->frame->sample_rate, av_get_sample_fmt_name(is->frame->format), av_frame_get_channels(is->frame), |
2421 | 2421 |
is->audio_tgt.freq, av_get_sample_fmt_name(is->audio_tgt.fmt), is->audio_tgt.channels); |
2422 |
+ swr_free(&is->swr_ctx); |
|
2422 | 2423 |
break; |
2423 | 2424 |
} |
2424 | 2425 |
is->audio_src.channel_layout = dec_channel_layout; |
... | ... |
@@ -2454,7 +2455,8 @@ static int audio_decode_frame(VideoState *is) |
2454 | 2454 |
} |
2455 | 2455 |
if (len2 == out_count) { |
2456 | 2456 |
av_log(NULL, AV_LOG_WARNING, "audio buffer is probably too small\n"); |
2457 |
- swr_init(is->swr_ctx); |
|
2457 |
+ if (swr_init(is->swr_ctx) < 0) |
|
2458 |
+ swr_free(&is->swr_ctx); |
|
2458 | 2459 |
} |
2459 | 2460 |
is->audio_buf = is->audio_buf1; |
2460 | 2461 |
resampled_data_size = len2 * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt); |