Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#41 small memory leak in udta.c

closed-fixed
nobody
quicktime (16)
5
2003-04-18
2002-03-23
Anonymous
No

i need to decode videos in a never-ending loop and
noticed a small memory leak when just running

while(1) {
qtfile = quicktime_open(filename, 1, 0);
quicktime_close(qtfile);
}

in tracking this down, if found in udta.c

int quicktime_udta_delete(quicktime_udta_t *udta)
{
if(udta->copyright_len)
{
free(udta->copyright);
}
if(udta->name_len)
{
free(udta->name);
}
if(udta->info_len)
{
free(udta->info);
}
quicktime_udta_init(udta);
return 0;
}

the problem in calling quicktime_udta_init at the end
is the fact that
udta->info = malloc(strlen(DEFAULT_INFO) + 1);
is allocated again and never freed.

i therefore changed to code to:

int quicktime_udta_delete(quicktime_udta_t *udta)
{
if(udta->copyright_len)
{
free(udta->copyright);
udta->copyright_len = 0;
}
if(udta->name_len)
{
free(udta->name);
udta->name_len = 0;
}
if(udta->info_len)
{
free(udta->info);
udta->info_len = 0;
}
return 0;
}

Discussion

    • status: open --> closed-fixed