libbluray | branch: master | hpi1 <h...@anonymous.org> | Sun Aug 7 17:17:16 2016 +0300| [749382d001de438b426f8bad43823fe90838ca5d] | committer: hpi1
rle_begin(): check for errors > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=749382d001de438b426f8bad43823fe90838ca5d --- src/libbluray/decoders/graphics_controller.c | 4 +++- src/libbluray/decoders/rle.c | 4 +++- src/libbluray/decoders/rle.h | 11 ++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/libbluray/decoders/graphics_controller.c b/src/libbluray/decoders/graphics_controller.c index 98f3239..c801f80 100644 --- a/src/libbluray/decoders/graphics_controller.c +++ b/src/libbluray/decoders/graphics_controller.c @@ -971,7 +971,9 @@ static int _render_textst_region(GRAPHICS_CONTROLLER *p, int64_t pts, BD_TEXTST_ uint16_t y; RLE_ENC rle; - rle_begin(&rle); + if (!rle_begin(&rle)) { + return -1; + } for (y = 0, bmp_y = 0; y < style->region_info.region.height; y++) { if (y < style->text_box.ypos || y >= style->text_box.ypos + style->text_box.height) { diff --git a/src/libbluray/decoders/rle.c b/src/libbluray/decoders/rle.c index 22183f8..4420542 100644 --- a/src/libbluray/decoders/rle.c +++ b/src/libbluray/decoders/rle.c @@ -69,7 +69,9 @@ BD_PG_RLE_ELEM *rle_crop_object(const BD_PG_RLE_ELEM *orig, int width, int x1 = crop_x + crop_w; /* first pixel outside of cropped region */ int x, y; - rle_begin(&rle); + if (!rle_begin(&rle)) { + return NULL; + } /* skip crop_y */ for (y = 0; y < crop_y; y++) { diff --git a/src/libbluray/decoders/rle.h b/src/libbluray/decoders/rle.h index a8e121e..1cd70e0 100644 --- a/src/libbluray/decoders/rle.h +++ b/src/libbluray/decoders/rle.h @@ -46,14 +46,17 @@ typedef struct { BD_PRIVATE BD_PG_RLE_ELEM *rle_crop_object(const BD_PG_RLE_ELEM *orig, int width, int crop_x, int crop_y, int crop_w, int crop_h); -static inline void rle_begin(RLE_ENC *p) +static inline int rle_begin(RLE_ENC *p) { p->num_elem = 1024; p->free_elem = 1024; p->elem = refcnt_realloc(NULL, p->num_elem * sizeof(BD_PG_RLE_ELEM)); - + if (!p->elem) { + return 0; + } p->elem->len = 0; p->elem->color = 0xffff; + return 1; } static inline BD_PG_RLE_ELEM *rle_get(RLE_ENC *p) @@ -65,7 +68,9 @@ static inline BD_PG_RLE_ELEM *rle_get(RLE_ENC *p) static inline void rle_end(RLE_ENC *p) { BD_PG_RLE_ELEM *start = rle_get(p); - bd_refcnt_dec(start); + if (start) { + bd_refcnt_dec(start); + } p->elem = NULL; } _______________________________________________ libbluray-devel mailing list libbluray-devel@videolan.org https://mailman.videolan.org/listinfo/libbluray-devel