fixed memory and jnigen version, checks null buffers