Opened 18 years ago
Closed 18 years ago
#1339 closed defect (invalid)
subreader.c:1411: Memory leak: sub
| Reported by: | Owned by: | reimar | |
|---|---|---|---|
| Priority: | normal | Component: | core |
| Version: | HEAD | Severity: | normal |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Reproduced by developer: | no | Analyzed by developer: | no |
Description
When CONFIG_SORTSUB is defined, variable sub leaks memory on line 1411 in file subreader.c. First memory is allocated with malloc and pointer is saved to sub. Later a new value is saved into sub and previous allocation leaks.
#ifdef CONFIG_SORTSUB
sub = malloc(sizeof(subtitle));
This is to deal with those formats (AQT & Subrip) which define the end of a subtitle
as the beginning of the following
previous_sub_end = 0;
#endif
while(1){
if(sub_num>=n_max){
n_max+=16;
first=realloc(first,n_max*sizeof(subtitle));
}
#ifndef CONFIG_SORTSUB
sub = &first[sub_num];
#endif

Shouldn't read code full of ifdefs at 2:00 am. The latter ifdef was ifndef, so there is no leak at that point of code. Sorry.