p2sr / mdp

mlugg's demo parser
The Unlicense
1 stars 2 forks source link

Fix memory leaks found by ASAN #6

Closed NeKzor closed 3 months ago

NeKzor commented 11 months ago

Follow-up of #5

Summary

1.) The switch case statement on SAR_DATA_ENTITY_INPUT_SLOT has a fall-through here: https://github.com/p2sr/mdp/blob/4a580f63eb5c70bd1371153f2ff1ad219a1598fa/src/demo.c#L155-L158 but this case is missing in _sar_data_free: https://github.com/p2sr/mdp/blob/4a580f63eb5c70bd1371153f2ff1ad219a1598fa/src/demo.c#L30-L37

2.) Missing call to closedir after opendir: https://github.com/p2sr/mdp/blob/4a580f63eb5c70bd1371153f2ff1ad219a1598fa/src/main.c#L301-L325

3.) strdup allocated header fields are not freed: https://github.com/p2sr/mdp/blob/4a580f63eb5c70bd1371153f2ff1ad219a1598fa/src/demo.c#L546-L550 https://github.com/p2sr/mdp/blob/4a580f63eb5c70bd1371153f2ff1ad219a1598fa/src/demo.c#L84-L91