summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2017-07-17 11:31:49 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2017-07-20 05:31:28 +0000
commit73abe390470c5989c99b4b586bf5e3dac77ce897 (patch)
tree9d8b10c3ae6898b2742c428eec33778f83f5eb83
parentf6c3b05484f595938538f6897160165ccb1e7f0f (diff)
downloadlibdrm-73abe390470c5989c99b4b586bf5e3dac77ce897.tar.gz
libdrm-73abe390470c5989c99b4b586bf5e3dac77ce897.tar.bz2
libdrm-73abe390470c5989c99b4b586bf5e3dac77ce897.zip
It does not check memory allocation result even though it can be failed. So, add null check and if failed, handle errors. Change-Id: Ia0f8daed3be118e27ac6795dc41f52d8780b3568 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r--tests/ipptest/util.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/ipptest/util.c b/tests/ipptest/util.c
index c8efe3d3..bf8ffad8 100644
--- a/tests/ipptest/util.c
+++ b/tests/ipptest/util.c
@@ -411,12 +411,29 @@ void util_draw_buffer_yuv(void **addr, unsigned int width, unsigned int height)
unsigned char *y, *u, *v, *u422, *v422;
img_ptr = malloc(width * height * 4);
+ if (!img_ptr)
+ return;
+
y = malloc(width * height);
+ if (!y)
+ goto err_free_img;
+
u = malloc(width * height);
+ if (!u)
+ goto err_free_y;
+
v = malloc(width * height);
+ if (!v)
+ goto err_free_u;
u422 = malloc(width * (height / 2));
+ if (!u422)
+ goto err_free_v;
+
v422 = malloc(width * (height / 2));
+ if (!v422)
+ goto err_free_u422;
+
/* Get RGB fmt Image */
fill_smpte_rgb32(img_ptr, width, height, width * 4);
@@ -451,7 +468,17 @@ void util_draw_buffer_yuv(void **addr, unsigned int width, unsigned int height)
memcpy(addr[EXYNOS_DRM_PLANAR_CB], u422, width * (height / 2));
memcpy(addr[EXYNOS_DRM_PLANAR_CR], v422, width * (height / 2));
- free(img_ptr); free(y); free(u); free(v); free(u422); free(v422);
+ free(v422);
+err_free_u422:
+ free(u422);
+err_free_v:
+ free(v);
+err_free_u:
+ free(u);
+err_free_y:
+ free(y);
+err_free_img:
+ free(img_ptr);
}
int util_write_bmp(const char *file, const void *data, unsigned int width,