framing: check for overflow on growing buffer

newsize is a long, but storage is an int. This means the allocation
could succeed but storage would overflow.

Closes #2300
2 jobs for master in 1 minute and 1 second (queued for 2 seconds)
latest
Status Job ID Name Coverage
  Build
passed #10731
docker
autoconf

00:01:01

passed #10732
docker
cmake

00:00:28