From 8b135229041a99a61e5c1e59824d998f3c89a616 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 23 Feb 2004 14:11:16 +0000 Subject: [PATCH] -memory leaks fixed - INSERT INTO objectName .... was not quoted correctly --- helm/metadata/extractor/sthandler.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/helm/metadata/extractor/sthandler.c b/helm/metadata/extractor/sthandler.c index d02895293..87e0d49c7 100644 --- a/helm/metadata/extractor/sthandler.c +++ b/helm/metadata/extractor/sthandler.c @@ -249,7 +249,15 @@ void print_all(about,conn) void print_name(char *name, char *uri) { - printf("INSERT INTO objectName VALUES ('%s', '%s');\n",uri,name); + size_t len = strlen(uri) + 1; + char *quri = malloc (sizeof(char) * len * 2); + PQescapeString(quri,uri,len); + len = strlen(name) + 1; + char *qname = malloc (sizeof(char) * len * 2); + PQescapeString(qname,name,len); + printf("INSERT INTO objectName VALUES ('%s', '%s');\n",quri,qname); + free(quri); + free(qname); } /****************************************************************/ @@ -294,6 +302,7 @@ void print_mainhyp(about,uri,l) char *qabout = malloc (sizeof(char) * len * 2); PQescapeString(qabout,about,len); printf("INSERT INTO refRel VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d);\n",qabout,curr->val); + free(qabout); curr = curr->next; } } @@ -307,6 +316,7 @@ void print_mainhyp(about,uri,l) char *qabout = malloc (sizeof(char) * len * 2); PQescapeString(qabout,about,len); printf("INSERT INTO refSort VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d, '%s');\n",qabout,curr->val,uri); + free(qabout); curr = curr->next; } } @@ -323,6 +333,8 @@ void print_mainhyp(about,uri,l) quri = malloc (sizeof(char) * len * 2); PQescapeString(quri,uri,len); printf("INSERT INTO refObj VALUES ('%s', '%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d);\n",qabout,quri,curr->val); + free(qabout); + free(quri); curr = curr->next; } } @@ -341,6 +353,7 @@ void print_mainconcl(about,uri,depth) char *qabout = malloc (sizeof(char) * len * 2); PQescapeString(qabout,about,len); printf("INSERT INTO refRel VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d);\n",qabout,depth); + free(qabout); } else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) || (!strcmp(uri,"Set"))) @@ -349,6 +362,7 @@ void print_mainconcl(about,uri,depth) char *qabout = malloc (sizeof(char) * len * 2); PQescapeString(qabout,about,len); printf("INSERT INTO refSort VALUES ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d, '%s');\n",qabout,depth,uri); + free(qabout); } else { @@ -360,6 +374,8 @@ void print_mainconcl(about,uri,depth) quri = malloc (sizeof(char) * len * 2); PQescapeString(quri,uri,len); printf("INSERT INTO refObj VALUES ('%s', '%s','http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d);\n",qabout,quri,depth); + free(qabout); + free(quri); } } @@ -389,6 +405,8 @@ void print_one(about,uri,pos) position="MainConclusion"; /* This should never happen */ printf("INSERT INTO refObj VALUES ('%s', '%s', \ 'http://www.cs.unibo.it/helm/schemas/schema-helm#%s', NULL);\n",qabout,quri,position); + free(qabout); + free(quri); } /* The following function allocates a bucket for an identifier. */ -- 2.39.2