Fixes #41. OOM exception from bad input causing too large a byte buffer to be allocated.