Skip to content

Fix TFOBJ_TYPE_LIST memory leak#1

Open
davc0n wants to merge 1 commit intoantirez:mainfrom
davc0n:fix-memory-leak
Open

Fix TFOBJ_TYPE_LIST memory leak#1
davc0n wants to merge 1 commit intoantirez:mainfrom
davc0n:fix-memory-leak

Conversation

@davc0n
Copy link
Copy Markdown

@davc0n davc0n commented Mar 28, 2026

Hi Salvatore,

Thank you very much for the C course :)

This small PR fixes a missing free call for TFOBJ_TYPE_LIST, elements are freed in the loop but the list itself is not (this is handled correctly in listPopType), and a crash in case of syntax error (compile method returns NULL, which in main was passed to printf).

Moreover changes the while loop of compile method to read the pointed value and not the pointer itself (which is never set to NULL and so the condition is always true), it is likely a typo (ref. lesson 2, minute 25).
The program worked anyway because of the break statement, which is still necessary because of parseSpaces, though someone learning might be confused seeing that while condition.

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.

1 participant