/* Read the next element as an ASCII string. 0 is success, < 0 is failure.  */
static int ebml_read_ascii(ByteIOContext *pb, int size, char **str)
/* Read the next element as an ASCII string. 0 is success, < 0 is failure.  */
static int ebml_read_ascii(ByteIOContext *pb, int size, char **str)
{
    av_free(*str);
    if (!(*str = av_malloc(size + 1)))
        return AVERROR(ENOMEM);
    if (get_buffer(pb, (uint8_t *) *str, size) != size) {
        av_free(*str);
        return AVERROR(EIO);
    }
    (*str)[size] = '\0';
    return 0;
}