From d8d50f3d608049fdf29849e8889c2ed85cf6cea1 Mon Sep 17 00:00:00 2001 From: Li kunyu Date: Thu, 15 Dec 2022 15:36:37 +0800 Subject: serial: Add check after malloc allocation (#878) --- camlibs/jd11/serial.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/camlibs/jd11/serial.c b/camlibs/jd11/serial.c index 31d3701e4..3a0325ee4 100644 --- a/camlibs/jd11/serial.c +++ b/camlibs/jd11/serial.c @@ -507,6 +507,12 @@ jd11_get_image_full( } gp_file_append(file, IMGHEADER, strlen(IMGHEADER)); data = malloc(640*480*3); + if (!data) { + free(uncomp[0]);free(uncomp[1]);free(uncomp[2]); + free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs); + return GP_ERROR_NO_MEMORY; + } + if (!raw) { unsigned char *bayerpre; s = bayerpre = malloc(640*480); -- cgit v1.2.1