Fix a memory leak
This commit is contained in:
parent
3a3014f9a3
commit
3128d3c646
@ -14,7 +14,7 @@ bool replace(tSyntaxElement* tree, tProcessingData* pdata) {
|
|||||||
if (tree->type == TOKEN)
|
if (tree->type == TOKEN)
|
||||||
if (strcmp(tree->content.string, pd->data.replace.replacethis) == 0) {
|
if (strcmp(tree->content.string, pd->data.replace.replacethis) == 0) {
|
||||||
didreplace = true;
|
didreplace = true;
|
||||||
free(tree->content.string);
|
free(tree->content.none);
|
||||||
tSyntaxElement* clone = se_clone_no_next(pd->data.replace.replacewiththis, tree);
|
tSyntaxElement* clone = se_clone_no_next(pd->data.replace.replacewiththis, tree);
|
||||||
tree->content = clone->content;
|
tree->content = clone->content;
|
||||||
tree->type = clone->type;
|
tree->type = clone->type;
|
||||||
@ -53,8 +53,10 @@ bool process_find(tSyntaxElement* tree, tProcessingData** p_pdata) {
|
|||||||
void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
||||||
tProcessingData* pd = pdata;
|
tProcessingData* pd = pdata;
|
||||||
bool deffound = false;
|
bool deffound = false;
|
||||||
|
tProcessingData* firstpd = NULL;
|
||||||
if (pd == NULL) {
|
if (pd == NULL) {
|
||||||
pd = calloc(1,sizeof(tProcessingData));
|
pd = calloc(1,sizeof(tProcessingData));
|
||||||
|
firstpd = pd;
|
||||||
}
|
}
|
||||||
deffound = process_find(tree, &pd);
|
deffound = process_find(tree, &pd);
|
||||||
if (tree->next != NULL) {
|
if (tree->next != NULL) {
|
||||||
@ -72,4 +74,8 @@ void process(tSyntaxElement* tree, tProcessingData* pdata) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pd != pdata)
|
||||||
|
free(pd);
|
||||||
|
if (firstpd != pd && firstpd != NULL)
|
||||||
|
free(firstpd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user