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
515 s->sao_pixel_buffer_v[c_idx] =515 s->sao_pixel_buffer_v[c_idx] =
516 av_malloc((h * 2 * sps->ctb_width) <<516 av_malloc((h * 2 * sps->ctb_width) <<
517 sps->pixel_shift);517 sps->pixel_shift);
518 if (!s->sao_pixel_buffer_h[c_idx] ||
519 !s->sao_pixel_buffer_v[c_idx])
520 goto fail;
518 }521 }
519 }522 }
520 523
@@ -525,6 +528,10 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps, · 4 unmodified lines
525 528
526fail:529fail:
527 pic_arrays_free(s);530 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 }
528 s->ps.sps = NULL;535 s->ps.sps = NULL;
529 return ret;536 return ret;
530}537}
@@ -2624,13 +2631,19 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 2093 unmodified lines
2624 2631
2625 ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);2632 ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
2626 2633
2627 if (!s->sList[1]) {2634 for (i = 1; i < s->threads_number; i++) {
2628 for (i = 1; i < s->threads_number; i++) {2635 if (s->sList[i] && s->HEVClcList[i])
2629 s->sList[i] = av_malloc(sizeof(HEVCContext));2636 continue;
2630 memcpy(s->sList[i], s, sizeof(HEVCContext));2637 av_freep(&s->sList[i]);
2631 s->HEVClcList[i] = av_mallocz(sizeof(HEVCLocalContext));2638 av_freep(&s->HEVClcList[i]);
2632 s->sList[i]->HEVClc = 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;
2633 }2644 }
2645 memcpy(s->sList[i], s, sizeof(HEVCContext));
2646 s->sList[i]->HEVClc = s->HEVClcList[i];
2634 }2647 }
2635 2648
2636 offset = (lc->gb.index >> 3);2649 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