shorten: check output buffer size before decoding