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

fix: add final freeing of Stack to freeStack #1085

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/clean.c
Expand Up @@ -1629,7 +1629,7 @@ void TY_(BQ2Div)( TidyDocImpl* doc, Node *node )

node = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}


Expand Down Expand Up @@ -2644,7 +2644,7 @@ void TY_(FixLanguageInformation)(TidyDocImpl* doc, Node* node, Bool wantXmlLang,

node = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}

/*
Expand Down Expand Up @@ -2754,7 +2754,7 @@ void TY_(FixAnchors)(TidyDocImpl* doc, Node *node, Bool wantName, Bool wantId)

node = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}

/* Issue #567 - move style elements from body to head
Expand Down Expand Up @@ -2798,7 +2798,7 @@ static void StyleToHead(TidyDocImpl* doc, Node *head, Node *node, Bool fix, int
indent--;
}
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}


Expand Down
2 changes: 1 addition & 1 deletion src/gdoc.c
Expand Up @@ -139,7 +139,7 @@ static void CleanNode( TidyDocImpl* doc, Node *node )
}
child = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/lexer.c
Expand Up @@ -4538,11 +4538,12 @@ FUNC_UNUSED Node* TY_(peek)(Stack *stack)
/**
* Frees the stack when done.
*/
void TY_(freeStack)(Stack *stack)
void TY_(freeStack)(Stack *stack, TidyDocImpl *doc)
{
TidyFree( stack->allocator, stack->firstNode );
stack->top = -1;
stack->capacity = 0;
stack->firstNode = NULL;
stack->allocator = NULL;
TidyFree( doc->allocator, stack)
Copy link

@Kijewski Kijewski Jul 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a semicolon missing at the end of the line.

}
2 changes: 1 addition & 1 deletion src/lexer.h
Expand Up @@ -731,7 +731,7 @@ TY_PRIVATE Node* TY_(peek)(Stack *stack);
/**
* Frees the stack when done.
*/
TY_PRIVATE void TY_(freeStack)(Stack *stack);
TY_PRIVATE void TY_(freeStack)(Stack *stack, TidyDocImpl *doc);


/** @}
Expand Down
2 changes: 1 addition & 1 deletion src/parser.c
Expand Up @@ -584,7 +584,7 @@ static void CleanSpaces(TidyDocImpl* doc, Node* node)

node = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}


Expand Down
6 changes: 3 additions & 3 deletions src/tidylib.c
Expand Up @@ -1804,7 +1804,7 @@ static void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )

node = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}
/*****************************************************************************
* END HTML5 STUFF
Expand Down Expand Up @@ -1935,7 +1935,7 @@ static void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )

node = next ? next : TY_(pop)(stack);
}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}


Expand Down Expand Up @@ -2091,7 +2091,7 @@ void dbg_show_all_nodes( TidyDocImpl* doc, Node *node, int indent )
}

}
TY_(freeStack)(stack);
TY_(freeStack)(stack, doc);
}
}
#endif
Expand Down