summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-10-20 10:59:02 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-10-20 11:30:13 +0200
commit6d6ccbae4cee8d6e4f70154d919e5cfe6fec8489 (patch)
tree66f498ec123bc79248c00647d2b22b6dbf5e991e /doc/examples
parent04bf2e7f0e9cf389f0756f0a413b7b275a75334f (diff)
examples/decoding_encoding: add missing checks on avcodec_alloc_context3()
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/decoding_encoding.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
index 24b9b6b7e6..c2401fb40d 100644
--- a/doc/examples/decoding_encoding.c
+++ b/doc/examples/decoding_encoding.c
@@ -121,6 +121,10 @@ static void audio_encode_example(const char *filename)
}
c = avcodec_alloc_context3(codec);
+ if (!c) {
+ fprintf(stderr, "Could not allocate audio codec context\n");
+ exit(1);
+ }
/* put sample parameters */
c->bit_rate = 64000;
@@ -252,6 +256,10 @@ static void audio_decode_example(const char *outfilename, const char *filename)
}
c = avcodec_alloc_context3(codec);
+ if (!c) {
+ fprintf(stderr, "Could not allocate audio codec context\n");
+ exit(1);
+ }
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
@@ -346,6 +354,10 @@ static void video_encode_example(const char *filename, int codec_id)
}
c = avcodec_alloc_context3(codec);
+ if (!c) {
+ fprintf(stderr, "Could not allocate video codec context\n");
+ exit(1);
+ }
/* put sample parameters */
c->bit_rate = 400000;
@@ -501,6 +513,11 @@ static void video_decode_example(const char *outfilename, const char *filename)
}
c = avcodec_alloc_context3(codec);
+ if (!c) {
+ fprintf(stderr, "Could not allocate video codec context\n");
+ exit(1);
+ }
+
if(codec->capabilities&CODEC_CAP_TRUNCATED)
c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */