Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
opentv: fix memory leaks for regex patterns
- Loading branch information
Showing
1 changed file
with
36 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b2bdcb3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi perex,
just to understand, I'm not sure where are the memory leaks you found.
I can see that you reverted to the use of statically allocated opentv_pattern_list_t inside opentv_module_t: I agree that this fits in a better way with the small size of opentv_pattern_list_t. My fault.
Maybe you misunderstood the fact that in case of non-compiling-pattern I thought to still create an element in the list but just with plain-text format and the compiled element was supposed to be NULL (so skipped during the apply).
It is not a complain: I just want to learn in case.
b2bdcb3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diraimondo : The opentv_pattern_list_t calloc was not freed. Also, you cannot use FOREACH loop when you free the structure in the tailq (because you need the ->next pointer from this structure to next iteration). I detected these fault using the valgrind tool.
I just optimized things, if you like to keep the failed regexes, you may add a new member like 'enabled' to the opentv_pattern_t structure.
b2bdcb3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perexg Yes, I forgot to a
free(l);in procedure_opentv_free_pattern_list, seetvheadend/src/epggrab/module/opentv.c
Line 777 in f419834
I'm not sure to understand the problem with the FOREACH and the free of the structure: I removed the element from the tailq before to freeing it (see above link), so I thought it was safe.
Thanks anyway.
b2bdcb3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diraimondo : The FOREACH macro uses the next list pointer from the removed structure (it's cached)..
b2bdcb3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diraimondo : the loop is something like for (p = first; p; p = p->next) ; so if you free(p) inside the for body the p is invalid to move to the next interation...
b2bdcb3There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, now it is more clear. I've not looked at the code of the macro and I was used to python.
Thanks.