setByteArray(): avoid potential signed integer overflow. Pointed by Hendra Gunadi. No actual problem known (which does not mean there wouldn't be any. Particularly on 32bit builds)

This commit is contained in:
Even Rouault 2019-08-16 19:47:42 +02:00
parent 4bb584a35f
commit 1302ffb350
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D

View File

@ -46,8 +46,8 @@ setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
*vpp = 0;
}
if (vp) {
tmsize_t bytes = (tmsize_t)(nmemb * elem_size);
if (elem_size && bytes / elem_size == nmemb)
tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL);
if (elem_size)
*vpp = (void*) _TIFFmalloc(bytes);
if (*vpp)
_TIFFmemcpy(*vpp, vp, bytes);