[MPlayer-dev-eng] [PATCH] memory leak in vobsub.c

Erwin Beckers E.Beckers at tss.nl
Wed Feb 26 15:50:04 CET 2003


Hi,
 
I just found a memory leak in vobsub.c in vobsub_parse_one_line() where the variable 'line' doesnt always get deleted 
i corrected it so the function now looks like this:
static int
vobsub_parse_one_line(vobsub_t *vob, rar_stream_t *fd)
{
    ssize_t line_size;
    int res = -1;
    do
    {
        size_t line_reserve = 0;
        char *line = NULL;
        line_size = getline(&line, &line_reserve, fd);
        if (line_size < 0)
        {
            if (line)
                free(line);
            break;
        }
        if (*line == 0 || *line == '\r' || *line == '\n' || *line == '#')
        {
          /* PATCH free line here as well*/
          if (line)
                free(line);
          continue;
        }
        else if (strncmp("langidx:", line, 8) == 0)
            res = vobsub_set_lang(line);
        else if (strncmp("delay:", line, 6) == 0)
            res = vobsub_parse_delay(vob, line);
        else if (strncmp("id:", line, 3) == 0)
            res = vobsub_parse_id(vob, line + 3);
        else if (strncmp("palette:", line, 8) == 0)
            res = vobsub_parse_palette(vob, line + 8);
        else if (strncmp("size:", line, 5) == 0)
            res = vobsub_parse_size(vob, line + 5);
        else if (strncmp("org:", line, 4) == 0)
            res = vobsub_parse_origin(vob, line + 4);
        else if (strncmp("timestamp:", line, 10) == 0)
            res = vobsub_parse_timestamp(vob, line + 10);
        else if (strncmp("custom colors:", line, 14) == 0)
            //custom colors: ON/OFF, tridx: XXXX, colors: XXXXXX, XXXXXX, XXXXXX,XXXXXX
            res = vobsub_parse_cuspal(vob, line) + vobsub_parse_tridx(line) + vobsub_parse_custom(vob, line);
        else
        {
            //mp_msg(MSGT_VOBSUB,MSGL_V, "vobsub: ignoring %s", line);
            continue;
        }
          /* PATCH free line here as well*/
        if (line)
            free(line);
        
        if (res < 0)
        {
            mp_msg(MSGT_VOBSUB,MSGL_ERR,  "ERROR in %s", line);       
            break;
        }
    }
    while (1);
    return res;
}

 
 
 
Erwin Beckers

Solution Designer

Telematic System & Services BV

Hanzeweg 14

2803 MC Gouda

tel. +31-(0)182-531646

fax. +31-(0)182-535393

E-Mail: e.beckers at tss.nl

Internet: http://www.tss.nl/

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20030226/1de65f4a/attachment.htm>


More information about the MPlayer-dev-eng mailing list