diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index 6cec90ca4..4d138340f 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -262,14 +262,15 @@ ptp_unpack_uint32_t_array(PTPParams *params, unsigned char* data, uint16_t offse { uint32_t n, i=0; + *array = NULL; n=dtoh32a(&data[offset]); if (n >= UINT_MAX/sizeof(uint32_t)) return 0; + if (!n) + return 0; *array = malloc (n*sizeof(uint32_t)); - while (n>i) { + for (i=0;i= UINT_MAX/sizeof(uint16_t)) return 0; + if (!n) + return 0; *array = malloc (n*sizeof(uint16_t)); - while (n>i) { + for (i=0;i