avcodec/textdec: add some memory checks