Skip to content

Conversation

@kknjh
Copy link
Contributor

@kknjh kknjh commented Jan 8, 2026

cmd_info and cmd_trace return directly when the parse_traces function returns a negative value, but parse_traces may also fail at the parse_trace step. Therefore, we add the release logic here to address this scenario.

cmd_info and cmd_trace return directly when the parse_traces function
returns a negative value, but parse_traces may also fail at the parse_trace step.
Therefore, we add the release logic here to address this scenario.

Signed-off-by: Feng Yang <[email protected]>
@Bojun-Seo
Copy link
Contributor

Great catch!

Applying this patch as-is might be a good approach, but the issue seems to stem from how the code is structured, making such problems more likely to occur. Instead of directly applying this patch, what if we restructure the function's role? That way, the overall structure would be better, and it would be easier to maintain.

I suggest modifying the parse_traces function so that it only retains its core functionality of parsing traces, while the memory allocation for this function is handled by the user—specifically, by the cmd_info and cmd_trace functions. By doing this, the functions responsible for allocating memory would also handle its deallocation, reducing the chance of developer errors and making maintenance easier.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants