bugfix: check buffer-size in decoding/encoding