avcodec/ass_split: fix a memory leak defect when realloc fails

Fixes #7019.
This commit is contained in:
Fan Gang 2018-02-13 15:38:59 +08:00 committed by Paul B Mahol
parent ddefd05507
commit c6e1966c1a
1 changed files with 3 additions and 3 deletions

View File

@ -249,7 +249,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf)
const ASSSection *section = &ass_sections[ctx->current_section]; const ASSSection *section = &ass_sections[ctx->current_section];
int *number = &ctx->field_number[ctx->current_section]; int *number = &ctx->field_number[ctx->current_section];
int *order = ctx->field_order[ctx->current_section]; int *order = ctx->field_order[ctx->current_section];
int *tmp, i, len; int i, len;
while (buf && *buf) { while (buf && *buf) {
if (buf[0] == '[') { if (buf[0] == '[') {
@ -280,9 +280,9 @@ static const char *ass_split_section(ASSSplitContext *ctx, const char *buf)
while (!is_eol(*buf)) { while (!is_eol(*buf)) {
buf = skip_space(buf); buf = skip_space(buf);
len = strcspn(buf, ", \r\n"); 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; return NULL;
order = tmp;
order[*number] = -1; order[*number] = -1;
for (i=0; section->fields[i].name; i++) for (i=0; section->fields[i].name; i++)
if (!strncmp(buf, section->fields[i].name, len)) { if (!strncmp(buf, section->fields[i].name, len)) {