Summary
There is a memory leak in the menu relabeling loop inside sentence_update_line_no.
Allocated strings are not always freed on early continue paths, and one allocated label is not freed after use.
Affected code
Problem details
In the loop:
- file_name is allocated, but if parsing fails or line number checks skip the entry, execution continues without freeing file_name.
- new_label is allocated and passed to gtk_menu_item_set_label, but is not freed afterward.
This causes repeated small leaks during UI operations that update sentence numbering.
Proposed fix
- Free file_name before each continue that exits the current iteration.
- Free new_label after gtk_menu_item_set_label.
- Add a guard for null label before strlen to avoid potential crash in edge cases.
Potential benefits
- Reduces cumulative memory usage during long editing sessions.
- Improves runtime stability and predictability.
- Low-risk, localized fix with minimal code change.
- Improves maintainability by reducing noise in memory diagnostics.
Summary
There is a memory leak in the menu relabeling loop inside sentence_update_line_no.
Allocated strings are not always freed on early continue paths, and one allocated label is not freed after use.
Affected code
Problem details
In the loop:
This causes repeated small leaks during UI operations that update sentence numbering.
Proposed fix
Potential benefits