Don't leak memory on realloc failure
Use reallocf instead of realloc to free on failure and deal with the
failure case more gracefully by freeing memory.
If anything fails, free buf as well as bufp.
Reported by: cppcheck
Sponsored by: EMC / Isilon Storage Division