History

check for coded_frame allocation failure in several audio encoders

Justin Ruggles committed 14 years ago

Commit a8bdf241 parent 255ad887 files · +17 −0Browse files

Unified · Split

7 files
  1. libavcodec/libgsm.c +4 −0
  2. libavcodec/libopencore-amr.c +3 −0
  3. libavcodec/libvo-aacenc.c +2 −0
  4. libavcodec/libvo-amrwbenc.c +2 −0
  5. libavcodec/mpegaudioenc.c +2 −0
  6. libavcodec/pcm.c +2 −0
  7. libavcodec/roqaudioenc.c +2 −0
libavcodec/libgsm.c+4−0
@@ -70,6 +70,10 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) { · 69 unmodified lines
7070 }
7171
7272 avctx->coded_frame= avcodec_alloc_frame();
73+ if (!avctx->coded_frame) {
74+ gsm_destroy(avctx->priv_data);
75+ return AVERROR(ENOMEM);
76+ }
7377
7478 return 0;
7579 }
libavcodec/libopencore-amr.c+3−0
@@ -196,10 +196,13 @@ static av_cold int amr_nb_encode_init(AVCodecContext *avctx) · 195 unmodified lines
196196
197197 avctx->frame_size = 160;
198198 avctx->coded_frame = avcodec_alloc_frame();
199+ if (!avctx->coded_frame)
200+ return AVERROR(ENOMEM);
199201
200202 s->enc_state = Encoder_Interface_init(s->enc_dtx);
201203 if (!s->enc_state) {
202204 av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
205+ av_freep(&avctx->coded_frame);
203206 return -1;
204207 }
205208
libavcodec/libvo-aacenc.c+2−0
@@ -39,6 +39,8 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 38 unmodified lines
3939 int index;
4040
4141 avctx->coded_frame = avcodec_alloc_frame();
42+ if (!avctx->coded_frame)
43+ return AVERROR(ENOMEM);
4244 avctx->frame_size = 1024;
4345
4446 voGetAACEncAPI(&s->codec_api);
libavcodec/libvo-amrwbenc.c+2−0
@@ -87,6 +87,8 @@ static av_cold int amr_wb_encode_init(AVCodecContext *avctx) · 86 unmodified lines
8787
8888 avctx->frame_size = 320;
8989 avctx->coded_frame = avcodec_alloc_frame();
90+ if (!avctx->coded_frame)
91+ return AVERROR(ENOMEM);
9092
9193 s->state = E_IF_init();
9294
libavcodec/mpegaudioenc.c+2−0
@@ -181,6 +181,8 @@ static av_cold int MPA_encode_init(AVCodecContext *avctx) · 180 unmodified lines
181181 }
182182
183183 avctx->coded_frame= avcodec_alloc_frame();
184+ if (!avctx->coded_frame)
185+ return AVERROR(ENOMEM);
184186
185187 return 0;
186188 }
libavcodec/pcm.c+2−0
@@ -49,6 +49,8 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx) · 48 unmodified lines
4949 avctx->bits_per_coded_sample = av_get_bits_per_sample(avctx->codec->id);
5050 avctx->block_align = avctx->channels * avctx->bits_per_coded_sample/8;
5151 avctx->coded_frame= avcodec_alloc_frame();
52+ if (!avctx->coded_frame)
53+ return AVERROR(ENOMEM);
5254
5355 return 0;
5456 }
libavcodec/roqaudioenc.c+2−0
@@ -59,6 +59,8 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) · 58 unmodified lines
5959 context->lastSample[0] = context->lastSample[1] = 0;
6060
6161 avctx->coded_frame= avcodec_alloc_frame();
62+ if (!avctx->coded_frame)
63+ return AVERROR(ENOMEM);
6264
6365 return 0;
6466 }

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