Avoid undefined behaviour after realloc()
commit2acdae154a3fb74b3bc5822839e1daef4c36ffbf
authorOlly Betts <olly@survex.com>
Fri, 15 Mar 2024 04:03:28 +0000 (15 17:03 +1300)
committerOlly Betts <olly@survex.com>
Fri, 15 Mar 2024 04:03:28 +0000 (15 17:03 +1300)
tree6d8136456f94b4aade436da041ca28942ac84c56
parent1000d9d15e4ff662157dc1cac8f636596c767516
Avoid undefined behaviour after realloc()

We were adjusting a pointer within the reallocated block by subtracting
the old block address and adding on the new one.  Technically this is
undefined behaviour, although in practice it seems likely it'll work,
but we can avoid it by just calculating the offset before the realloc().
src/img.c