Fail if the buffer is null. Fixes #358