History

avcodec/hevcdec: add some missing allocation checks

James Almer committed 5 years ago

Commit 22edf741 parent 089706e1 file · +19 −6Browse files

Unified · Split

libavcodec/hevcdec.c+19−6
@@ -515,6 +515,9 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, · 514 unmodified lines
515515 s->sao_pixel_buffer_v[c_idx] =
516516 av_malloc((h * 2 * sps->ctb_width) <<
517517 sps->pixel_shift);
518+ if (!s->sao_pixel_buffer_h[c_idx] ||
519+ !s->sao_pixel_buffer_v[c_idx])
520+ goto fail;
518521 }
519522 }
520523
@@ -525,6 +528,10 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, · 4 unmodified lines
525528
526529 fail:
527530 pic_arrays_free(s);
531+ for (i = 0; i < 3; i++) {
532+ av_freep(&s->sao_pixel_buffer_h[i]);
533+ av_freep(&s->sao_pixel_buffer_v[i]);
534+ }
528535 s->ps.sps = NULL;
529536 return ret;
530537 }
@@ -2624,13 +2631,19 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 2093 unmodified lines
26242631
26252632 ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
26262633
2627− if (!s->sList[1]) {
2628− for (i = 1; i < s->threads_number; i++) {
2629− s->sList[i] = av_malloc(sizeof(HEVCContext));
2630− memcpy(s->sList[i], s, sizeof(HEVCContext));
2631− s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));
2632− s->sList[i]->HEVClc = s->HEVClcList[i];
2634+ for (i = 1; i < s->threads_number; i++) {
2635+ if (s->sList[i] && s->HEVClcList[i])
2636+ continue;
2637+ av_freep(&s->sList[i]);
2638+ av_freep(&s->HEVClcList[i]);
2639+ s->sList[i] = av_malloc(sizeof(HEVCContext));
2640+ s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));
2641+ if (!s->sList[i] || !s->HEVClcList[i]) {
2642+ res = AVERROR_INVALIDDATA;
2643+ goto error;
26332644 }
2645+ memcpy(s->sList[i], s, sizeof(HEVCContext));
2646+ s->sList[i]->HEVClc = s->HEVClcList[i];
26342647 }
26352648
26362649 offset = (lc->gb.index >> 3);

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