[libbluray-devel] _decode_rle(): check realloc() return value
hpi1
git at videolan.org
Sun Dec 4 11:21:10 CET 2011
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sun Dec 4 12:15:59 2011 +0200| [afe9bcf1391a95914c3b7d443692adab6b2a0ee7] | committer: hpi1
_decode_rle(): check realloc() return value
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=afe9bcf1391a95914c3b7d443692adab6b2a0ee7
---
src/libbluray/decoders/pg_decode.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/src/libbluray/decoders/pg_decode.c b/src/libbluray/decoders/pg_decode.c
index 91ca4a6..b970d1e 100644
--- a/src/libbluray/decoders/pg_decode.c
+++ b/src/libbluray/decoders/pg_decode.c
@@ -116,6 +116,11 @@ static int _decode_rle(BITBUFFER *bb, BD_PG_OBJECT *p)
rle_size = 1;
p->img = realloc(p->img, rle_size * sizeof(BD_PG_RLE_ELEM));
+ if (!p->img) {
+ BD_DEBUG(DBG_DECODE | DBG_CRIT, "pg_decode_object(): relloc(%d) failed\n",
+ rle_size * sizeof(BD_PG_RLE_ELEM));
+ return 0;
+ }
while (!bb_eof(bb)) {
uint32_t len = 1;
@@ -145,8 +150,15 @@ static int _decode_rle(BITBUFFER *bb, BD_PG_OBJECT *p)
num_rle++;
if (num_rle >= rle_size) {
+ void *tmp = p->img;
rle_size *= 2;
p->img = realloc(p->img, rle_size * sizeof(BD_PG_RLE_ELEM));
+ if (!p->img) {
+ BD_DEBUG(DBG_DECODE | DBG_CRIT, "pg_decode_object(): relloc(%d) failed\n",
+ rle_size * sizeof(BD_PG_RLE_ELEM));
+ X_FREE(tmp);
+ return 0;
+ }
}
}
More information about the libbluray-devel
mailing list