[Libva] [PATCH 2/5] add assert check for potential NULL issue in test/encode/

Lim Siew Hoon siew.hoon.lim at intel.com
Fri Jul 1 03:13:22 UTC 2016


Signed-off-by: Lim Siew Hoon <siew.hoon.lim at intel.com>
---
 test/encode/avcenc.c        | 2 ++
 test/encode/h264encode.c    | 2 ++
 test/encode/jpegenc_utils.h | 2 ++
 test/encode/mpeg2vaenc.c    | 1 +
 4 files changed, 7 insertions(+)

diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c
index 74729fb..d5f2bd5 100644
--- a/test/encode/avcenc.c
+++ b/test/encode/avcenc.c
@@ -953,6 +953,7 @@ bitstream_start(bitstream *bs)
 {
     bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING;
     bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1);
+    assert(bs->buffer);
     bs->bit_offset = 0;
 }
 
@@ -990,6 +991,7 @@ bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits)
         if (pos + 1 == bs->max_size_in_dword) {
             bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING;
             bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int));
+            assert(bs->buffer);
         }
 
         bs->buffer[pos + 1] = val;
diff --git a/test/encode/h264encode.c b/test/encode/h264encode.c
index 9e20919..3d7b610 100644
--- a/test/encode/h264encode.c
+++ b/test/encode/h264encode.c
@@ -197,6 +197,7 @@ bitstream_start(bitstream *bs)
 {
     bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING;
     bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1);
+    assert(bs->buffer);
     bs->bit_offset = 0;
 }
 
@@ -234,6 +235,7 @@ bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits)
         if (pos + 1 == bs->max_size_in_dword) {
             bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING;
             bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int));
+            assert(bs->buffer);
         }
 
         bs->buffer[pos + 1] = val;
diff --git a/test/encode/jpegenc_utils.h b/test/encode/jpegenc_utils.h
index e003c7e..bb00c8b 100644
--- a/test/encode/jpegenc_utils.h
+++ b/test/encode/jpegenc_utils.h
@@ -65,6 +65,7 @@ bitstream_start(bitstream *bs)
 {
     bs->max_size_in_dword = BITSTREAM_ALLOCATE_STEPPING;
     bs->buffer = calloc(bs->max_size_in_dword * sizeof(int), 1);
+    assert(bs->buffer);
     bs->bit_offset = 0;
 }
 
@@ -105,6 +106,7 @@ bitstream_put_ui(bitstream *bs, unsigned int val, int size_in_bits)
         if (pos + 1 == bs->max_size_in_dword) {
             bs->max_size_in_dword += BITSTREAM_ALLOCATE_STEPPING;
             bs->buffer = realloc(bs->buffer, bs->max_size_in_dword * sizeof(unsigned int));
+            assert(bs->buffer);
         }
 
         bs->buffer[pos + 1] = val;
diff --git a/test/encode/mpeg2vaenc.c b/test/encode/mpeg2vaenc.c
index 93888d9..ad229b2 100644
--- a/test/encode/mpeg2vaenc.c
+++ b/test/encode/mpeg2vaenc.c
@@ -831,6 +831,7 @@ mpeg2enc_alloc_va_resources(struct mpeg2enc_context *ctx)
 
     max_entrypoints = vaMaxNumEntrypoints(ctx->va_dpy);
     entrypoint_list = malloc(max_entrypoints * sizeof(VAEntrypoint));
+    assert(entrypoint_list);
     vaQueryConfigEntrypoints(ctx->va_dpy,
                              ctx->profile,
                              entrypoint_list,
-- 
2.1.0



More information about the Libva mailing list