avcodec/cdgraphics: check buffer size before use