From ac7ab461cb991da2463e754a4b818dbe91861ba7 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 29 Feb 2016 23:35:06 +0100 Subject: [PATCH] handle an oom in getpropcodes --- camlibs/ptp2/ptp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index 336e86bf3..12633d46f 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -2797,8 +2797,12 @@ ptp_sony_get_vendorpropcodes (PTPParams* params, uint16_t **props, unsigned int if (psize1*2 + 2 + 4 < xsize) { psize2 = ptp_unpack_uint16_t_array(params,xdata+2+psize1*2+4, 0, xsize, &props2); } + *props = calloc(psize1+psize2, sizeof(uint16_t)); + if (!*props) { + ptp_debug (params, "oom during malloc?"); + return PTP_RC_OK; + } *size = psize1+psize2; - *props = malloc((psize1+psize2)*sizeof(uint16_t)); memcpy (*props, props1, psize1*sizeof(uint16_t)); memcpy ((*props)+psize1, props2, psize2*sizeof(uint16_t)); free (props1);