History

examples/decoding_encoding: add missing checks on avcodec_alloc_context3()

Stefano Sabatini committed 14 years ago

Commit 6d6ccba1 parent 04bf2e71 file · +17 −0Browse files

Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all

Unified · Split

doc/examples/decoding_encoding.c+17−0
@@ -121,6 +121,10 @@ static void audio_encode_example(const char *filename) · 120 unmodified lines
121121 }
122122
123123 c = avcodec_alloc_context3(codec);
124+ if (!c) {
125+ fprintf(stderr, "Could not allocate audio codec context\n");
126+ exit(1);
127+ }
124128
125129 /* put sample parameters */
126130 c->bit_rate = 64000;
@@ -252,6 +256,10 @@ static void audio_decode_example(const char *outfilename, const char *filename) · 125 unmodified lines
252256 }
253257
254258 c = avcodec_alloc_context3(codec);
259+ if (!c) {
260+ fprintf(stderr, "Could not allocate audio codec context\n");
261+ exit(1);
262+ }
255263
256264 /* open it */
257265 if (avcodec_open2(c, codec, NULL) < 0) {
@@ -346,6 +354,10 @@ static void video_encode_example(const char *filename, int codec_id) · 88 unmodified lines
346354 }
347355
348356 c = avcodec_alloc_context3(codec);
357+ if (!c) {
358+ fprintf(stderr, "Could not allocate video codec context\n");
359+ exit(1);
360+ }
349361
350362 /* put sample parameters */
351363 c->bit_rate = 400000;
@@ -501,6 +513,11 @@ static void video_decode_example(const char *outfilename, const char *filename) · 149 unmodified lines
501513 }
502514
503515 c = avcodec_alloc_context3(codec);
516+ if (!c) {
517+ fprintf(stderr, "Could not allocate video codec context\n");
518+ exit(1);
519+ }
520+
504521 if(codec->capabilities&CODEC_CAP_TRUNCATED)
505522 c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
506523

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t