Avoid "jump to label crosses initialization" error.

Move variable "buffer" into the while loop to avoid a compile error
with g++ 4.9.0.

Although earlier compiler versions did accept the code, jumping into the
scope of an variable length array is not allowed:
http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Variable-Length.html