examples/decoding_encoding: check av_samples_get_buffer_size() return code
Fixes CID1135756. Signed-off-by: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
parent
b242c156e5
commit
c65fe9e982
@ -170,6 +170,10 @@ static void audio_encode_example(const char *filename)
|
|||||||
* we calculate the size of the samples buffer in bytes */
|
* we calculate the size of the samples buffer in bytes */
|
||||||
buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
|
buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
|
||||||
c->sample_fmt, 0);
|
c->sample_fmt, 0);
|
||||||
|
if (!buffer_size) {
|
||||||
|
fprintf(stderr, "Could not get sample buffer size\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
samples = av_malloc(buffer_size);
|
samples = av_malloc(buffer_size);
|
||||||
if (!samples) {
|
if (!samples) {
|
||||||
fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
|
fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user