summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-03-21 09:13:02 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-03-21 13:25:27 +0100
commit22fa995ae81739aa1b7fcc5ffb277d1a46bda452 (patch)
tree1bb7991ff65a1b57b27a6027913d6b4c7ba1b13e /hwpfilter
parent06d132333deeb1580b7cc106dfb3ff4bc454178d (diff)
ofz#45816 Direct-leak
Change-Id: I73ed541c9a8fb6d9b0a8ee86ce7cf581721a9b73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131889 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/formula.cxx32
-rw-r--r--hwpfilter/source/grammar.cxx66
-rw-r--r--hwpfilter/source/nodes.h7
3 files changed, 51 insertions, 54 deletions
diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index f9ab4566668f..6093681b2de5 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -191,11 +191,11 @@ void Formula::makeIdentifier(Node *res)
case ID_CHARACTER :
#ifdef DEBUG
inds;
- fprintf(stderr,"<math:mi>%s</math:mi>\n",tmp->value);
+ fprintf(stderr,"<math:mi>%s</math:mi>\n",tmp->value.get());
indo;
#else
rstartEl("math:mi", mxList);
- rchars(OUString::createFromAscii(tmp->value));
+ rchars(OUString::createFromAscii(tmp->value.get()));
rendEl("math:mi");
#endif
break;
@@ -204,7 +204,7 @@ void Formula::makeIdentifier(Node *res)
#ifdef DEBUG
#else
rstartEl("math:mi", mxList);
- reucstr(tmp->value, strlen(tmp->value));
+ reucstr(tmp->value.get(), strlen(tmp->value.get()));
rendEl("math:mi");
#endif
}
@@ -213,22 +213,22 @@ void Formula::makeIdentifier(Node *res)
#ifdef DEBUG
inds;
fprintf(stderr,"<math:mi>%s</math:mi>\n",
- getMathMLEntity(tmp->value).c_str());
+ getMathMLEntity(tmp->value.get()).c_str());
indo;
#else
rstartEl("math:mi", mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value)));
+ runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get())));
rendEl("math:mi");
#endif
break;
case ID_NUMBER :
#ifdef DEBUG
inds;
- fprintf(stderr,"<math:mn>%s</math:mn>\n",tmp->value);
+ fprintf(stderr,"<math:mn>%s</math:mn>\n",tmp->value.get());
indo;
#else
rstartEl("math:mn", mxList);
- rchars(OUString::createFromAscii(tmp->value));
+ rchars(OUString::createFromAscii(tmp->value.get()));
rendEl("math:mn");
#endif
break;
@@ -236,10 +236,10 @@ void Formula::makeIdentifier(Node *res)
case ID_DELIMITER :
{
#ifdef DEBUG
- inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value); indo;
+ inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value.get()); indo;
#else
rstartEl("math:mo", mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value)));
+ runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get())));
rendEl("math:mo");
#endif
break;
@@ -370,7 +370,7 @@ void Formula::makeDecoration(Node *res)
int isover = 1;
Node *tmp = res->child;
if( !tmp ) return;
- if( !strncmp(tmp->value,"under", 5) )
+ if( !strncmp(tmp->value.get(),"under", 5) )
isover = 0;
#ifdef DEBUG
inds;
@@ -396,11 +396,11 @@ void Formula::makeDecoration(Node *res)
#ifdef DEBUG
inds;
fprintf(stderr,"<math:mo>%s</math:mo>\n",
- getMathMLEntity(tmp->value).c_str());
+ getMathMLEntity(tmp->value.get()).c_str());
indo;
#else
rstartEl("math:mo", mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value)));
+ runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get())));
rendEl("math:mo");
#endif
@@ -518,13 +518,13 @@ void Formula::makeFence(Node *res)
#ifdef DEBUG
inds;
fprintf(stderr,"<math:mfenced open=\"%s\" close=\"%s\">\n",
- getMathMLEntity(tmp->value).c_str(),
- getMathMLEntity(tmp->next->next->value).c_str());
+ getMathMLEntity(tmp->value.get()).c_str(),
+ getMathMLEntity(tmp->next->next->value.get()).c_str());
#else
padd("open", "CDATA",
- OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str())));
+ OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value.get()).c_str())));
padd("close", "CDATA",
- OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->next->next->value).c_str())));
+ OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->next->next->value.get()).c_str())));
rstartEl("math:mfenced", mxList);
mxList->clear();
#endif
diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 1545205472ee..199aab343208 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -514,55 +514,55 @@ yyreduce:
switch (yyn) {
case 1:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 2:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 3:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 4:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 5:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 6:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 7:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 8:
-{ yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 9:
-{ yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 10:
-{ yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 11:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 12:
-{ yyval.ptr = new Node(ID_DELIMITER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_DELIMITER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 13:
-{ yyval.ptr = new Node(ID_DELIMITER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_DELIMITER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 14:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Identifier : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 15:
-{ yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value = strdup("|"); debug("Identifier : '|'\n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value.reset(strdup("|")); debug("Identifier : '|'\n"); nodelist.emplace_back(yyval.ptr);
break;}
case 16:
-{ yyval.ptr = new Node(ID_NUMBER); yyval.ptr->value = strdup(yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_NUMBER); yyval.ptr->value.reset(strdup(yyvsp[0].dval)); debug("Number : %s\n",yyvsp[0].dval); nodelist.emplace_back(yyval.ptr);
break;}
case 17:
-{ yyval.ptr = new Node(ID_STRING); yyval.ptr->value = strdup(yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_STRING); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("String : %s\n",yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 18:
{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.emplace_back(yyval.ptr);
@@ -571,46 +571,46 @@ case 19:
{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.emplace_back(yyval.ptr);
break;}
case 20:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("("); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("(")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 21:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("["); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("[")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 22:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("{"); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("{")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 23:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("<"); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("<")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 24:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("|"); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("|")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 25:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value =strdup("||"); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup("||")); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 26:
-{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup(yyvsp[0].str); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("EQLeft \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 27:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(")"); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup(")")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 28:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("]"); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("]")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 29:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("}"); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("}")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 30:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(">"); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup(">")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 31:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("|"); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("|")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 32:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("||"); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup("||")); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 33:
-{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(yyvsp[0].str); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("EQRight \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 34:
{ yyval.ptr = new Node(ID_FENCE); yyval.ptr->child=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[-1].ptr; yyvsp[-1].ptr->next=yyvsp[0].ptr; debug("Fence \n"); nodelist.emplace_back(yyval.ptr);
@@ -649,13 +649,13 @@ case 45:
{ yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.emplace_back(yyval.ptr);
break;}
case 46:
-{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Accent : %s\n", yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 47:
{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.emplace_back(yyval.ptr);
break;}
case 48:
-{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
+{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->value.reset(strdup(yyvsp[0].str)); debug("Decoration : %s\n", yyvsp[0].str); nodelist.emplace_back(yyval.ptr);
break;}
case 49:
{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.emplace_back(yyval.ptr);
diff --git a/hwpfilter/source/nodes.h b/hwpfilter/source/nodes.h
index 9d238e75c945..dce473e13fa5 100644
--- a/hwpfilter/source/nodes.h
+++ b/hwpfilter/source/nodes.h
@@ -26,6 +26,7 @@
#include <vector>
#include <stdio.h>
#include <stdlib.h>
+#include <o3tl/deleter.hxx>
#include <osl/diagnose.h>
enum IDLIST {
@@ -68,7 +69,6 @@ class Node{
public:
explicit Node(int _id) : id(_id)
{
- value = nullptr;
child = nullptr;
next = nullptr;
#ifdef NODE_DEBUG
@@ -78,9 +78,6 @@ public:
}
~Node()
{
- if( value ) free( value );
- // if( child ) delete child;
- // if( next ) delete next;
next = nullptr;
child = nullptr;
#ifdef NODE_DEBUG
@@ -91,7 +88,7 @@ public:
public:
static int count; /* For memory debugging */
int id;
- char *value;
+ std::unique_ptr<char, o3tl::free_delete> value;
Node *child;
Node *next;
};