Opened 9 months ago

Last modified 9 months ago

#7019 new defect

A memory leak bug detected in file /libavcodec/ass_split.c

Reported by: fangang190 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: ass leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

No step needed for reproduce. 

There is a potential memory leak bug in file ass_split.c, here is the description.

A piece of memory is allocated on line 283. When executing the loop twice and if the av_realloc_array returns null the function returns without freeing the memory pointed by order.

        if (section->format_header && !order) {
            len = strlen(section->format_header);
            if (!strncmp(buf, section->format_header, len) && buf[len] == ':') {
                buf += len + 1;
                while (!is_eol(*buf)) {
                    buf = skip_space(buf);
                    len = strcspn(buf, ", \r\n");
283:                    if (!(tmp = av_realloc_array(order, (*number + 1), sizeof(*order))))
                        return NULL;
                    order = tmp;
                    order[*number] = -1;
                    for (i=0; section->fields[i].name; i++)
                        if (!strncmp(buf, section->fields[i].name, len)) {
                            order[*number] = i;
                            break;
                        }
                    (*number)++;
                    buf = skip_space(buf + len + (buf[len] == ','));
                }
                ctx->field_order[ctx->current_section] = order;
                goto next_line;
            }
        }

Suggested fix:
free(order) before return NULL; on line 284

Thanks
Gang
Sbrella

Change History (2)

comment:1 follow-up: Changed 9 months ago by cehoyos

  • Keywords ass added; Memory removed

Please send your patch - made with git format-patch to the FFmpeg development mailing list.

comment:2 in reply to: ↑ 1 Changed 9 months ago by fangang190

Replying to cehoyos:

Please send your patch - made with git format-patch to the FFmpeg development mailing list.

Sent.

Note: See TracTickets for help on using tickets.