X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fass_split.c;h=189272bbd98ebfb6999d83f0202b6607ada0655c;hb=d92f38c179591a608390ffa9fee59c309142e79d;hp=872528bdfa6df322e055435b0d0b05321d1cd450;hpb=4069096dd535ee99175c2a29c1a1f59c3fc110c1;p=ffmpeg diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c index 872528bdfa6..189272bbd98 100644 --- a/libavcodec/ass_split.c +++ b/libavcodec/ass_split.c @@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) const ASSSection *section = &ass_sections[ctx->current_section]; int *number = &ctx->field_number[ctx->current_section]; int *order = ctx->field_order[ctx->current_section]; - int *tmp, i, len; + int i, len; while (buf && *buf) { if (buf[0] == '[') { @@ -280,9 +280,9 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf) while (!is_eol(*buf)) { buf = skip_space(buf); len = strcspn(buf, ", \r\n"); - if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order)))) + if (av_reallocp_array(&order, (*number + 1), sizeof(*order)) != 0) return NULL; - order = tmp; + order[*number] = -1; for (i=0; section->fields[i].name; i++) if (!strncmp(buf, section->fields[i].name, len)) { @@ -376,6 +376,8 @@ ASSSplitContext *ff_ass_split(const char *buf) ASSSplitContext *ctx = av_mallocz(sizeof(*ctx)); if (!ctx) return NULL; + if (buf && !strncmp(buf, "\xef\xbb\xbf", 3)) // Skip UTF-8 BOM header + buf += 3; ctx->current_section = -1; if (ass_split(ctx, buf) < 0) { ff_ass_split_free(ctx);