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)
Status Name Job ID Coverage
  Build
passed autoconf #10731
docker

00:01:01

passed cmake #10732
docker

00:00:28