Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak when parsing Array Initializers #29

Open
cwalter-at opened this issue May 12, 2021 · 0 comments
Open

Memory leak when parsing Array Initializers #29

cwalter-at opened this issue May 12, 2021 · 0 comments

Comments

@cwalter-at
Copy link

The function ParseArrayInitializer first estimates the number of elements by calling itself again with DoAssignment=False. The problem in line 285. The ExpressionParser allocates the value on the stack.

picoc/parse.c

Line 285 in a97d94f

if (!ExpressionParse(Parser, &CValue))

As DoAssignment is false line 288 is not true and the variable is never released anymore.

I think the following pop condition below shall be added.

if (Parser->Mode == RunModeRun && DoAssignment) { ExpressionAssign(Parser, ArrayElement, CValue, false, NULL, 0, false); VariableStackPop(Parser, CValue); VariableStackPop(Parser, ArrayElement); } else if(Parser->Mode == RunModeRun) { VariableStackPop(Parser, CValue); }

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

No branches or pull requests

1 participant