History

libswresample/rematrix: Check for malloc errors

Michael Niedermayer committed 11 years ago

Commit 52acd221 parent e91debf1 file · +8 −0Browse files

Unified · Split

libswresample/rematrix.c+8−0
@@ -364,6 +364,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 363 unmodified lines
364364 if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){
365365 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int));
366366 s->native_one = av_mallocz(sizeof(int));
367+ if (!s->native_matrix || !s->native_one)
368+ return AVERROR(ENOMEM);
367369 for (i = 0; i < nb_out; i++)
368370 for (j = 0; j < nb_in; j++)
369371 ((int*)s->native_matrix)[i * nb_in + j] = lrintf(s->matrix[i][j] * 32768);
@@ -374,6 +376,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 4 unmodified lines
374376 }else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){
375377 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float));
376378 s->native_one = av_mallocz(sizeof(float));
379+ if (!s->native_matrix || !s->native_one)
380+ return AVERROR(ENOMEM);
377381 for (i = 0; i < nb_out; i++)
378382 for (j = 0; j < nb_in; j++)
379383 ((float*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
@@ -384,6 +388,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 4 unmodified lines
384388 }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){
385389 s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));
386390 s->native_one = av_mallocz(sizeof(double));
391+ if (!s->native_matrix || !s->native_one)
392+ return AVERROR(ENOMEM);
387393 for (i = 0; i < nb_out; i++)
388394 for (j = 0; j < nb_in; j++)
389395 ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];
@@ -395,6 +401,8 @@ av_cold int swri_rematrix_init(SwrContext *s){ · 5 unmodified lines
395401 // Only for dithering currently
396402 // s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double));
397403 s->native_one = av_mallocz(sizeof(int));
404+ if (!s->native_one)
405+ return AVERROR(ENOMEM);
398406 // for (i = 0; i < nb_out; i++)
399407 // for (j = 0; j < nb_in; j++)
400408 // ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j];

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