-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Issue:
freeEventList() in events.c only frees the EventNode container but never frees the eventParams payload allocated inside createEventNode().
In createEventNode(), every event type performs two separate heap allocations:
- The
EventNodestruct itself - A type-specific params struct (
HarvestParams,IrrigationParams, etc.) stored ineventParams
However, freeEventList() only frees the outer node:
void freeEventList(void) {
EventNode *curr, *prev;
curr = gEvents;
while (curr != NULL) {
prev = curr;
curr = curr->nextEvent;
free(prev);
}
}
Every event loaded from the events file leaks its parameter block.
Proposed Fix:
Free the internal parameter struct before freeing the node:
while (curr != NULL) {
prev = curr;
curr = curr->nextEvent;
if (prev->eventParams != NULL) {
free(prev->eventParams);
}
free(prev);
}
Note:Found while trying to understand events.c in preparation for the GSoC NetCDF I/O work. Happy to submit a PR with the fix if this is actually not intended behavior.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels