Changeset: 10c967840d07 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=10c967840d07
Modified Files:
monetdb5/mal/mal_atom.c
monetdb5/optimizer/opt_centipede.c
monetdb5/optimizer/opt_octopus.c
monetdb5/optimizer/opt_pushselect.c
monetdb5/scheduler/run_octopus.c
monetdb5/scheduler/srvpool.c
sql/backends/monet5/sql.c
sql/backends/monet5/sql_scenario.c
Branch: Jan2014
Log Message:
Minor errors detected by Coverity
diffs (251 lines):
diff --git a/monetdb5/mal/mal_atom.c b/monetdb5/mal/mal_atom.c
--- a/monetdb5/mal/mal_atom.c
+++ b/monetdb5/mal/mal_atom.c
@@ -110,7 +110,7 @@ int malAtomProperty(MalBlkPtr mb, InstrP
assert(pci != 0);
name = getFunctionId(pci);
tpe = getTypeIndex(getModuleId(pci), (int)strlen(getModuleId(pci)),
TYPE_any);
- if (tpe < 0 || tpe >= GDKatomcnt)
+ if (tpe < 0 || tpe >= MAXATOMS)
return 0;
assert(pci->fcn != NULL);
switch (name[0]) {
@@ -281,7 +281,7 @@ int malAtomSize(int size, int align, cha
void showAtoms(stream *fd)
{
int i;
- for (i = 0; BATatoms[i].name[0] && i < MAXATOMS; i++) {
+ for (i = 0; i < MAXATOMS && BATatoms[i].name[0]; i++) {
mnstr_printf(fd, "%s", BATatoms[i].name);
if (BATatoms[i + 1].name[0]) mnstr_printf(fd, ",");
}
diff --git a/monetdb5/optimizer/opt_centipede.c
b/monetdb5/optimizer/opt_centipede.c
--- a/monetdb5/optimizer/opt_centipede.c
+++ b/monetdb5/optimizer/opt_centipede.c
@@ -519,16 +519,22 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
plantag= OIDnew(1);
snprintf(nme,BUFSIZ,"%s_plan"OIDFMT,getFunctionId( getInstrPtr(mb,0)),
plantag);
s = newFunction(userRef, putName(nme, strlen(nme)),FUNCTIONsymbol);
- if ( s == NULL)
+ if ( s == NULL){
+ GDKfree(status);
+ GDKfree(vars);
return;
+ }
freeMalBlk(s->def);
s->def = copyMalBlk(mb);
plan = s->def;
limit = plan->stop;
old = plan->stmt;
- if ( newMalBlkStmt(plan,plan->ssize) < 0 )
+ if ( newMalBlkStmt(plan,plan->ssize) < 0 ){
+ GDKfree(status);
+ GDKfree(vars);
return;
+ }
#ifdef _DEBUG_OPT_CENTIPEDE_
mnstr_printf(cntxt->fdout,"#Remote plan framework\n");
@@ -955,6 +961,7 @@ OPTbakePlans(Client cntxt, MalBlkPtr mb,
#endif
GDKfree(old);
GDKfree(vars);
+ GDKfree(status);
}
/*
@@ -1087,6 +1094,8 @@ OPTcentipedeImplementation(Client cntxt,
if (msg || mb->errors ) {
/* restore MAL block */
mnstr_printf(cntxt->fdout,"#partition %s\n", msg?msg:"generic
error");
+ if( msg)
+ GDKfree(msg);
#ifdef _DEBUG_OPT_CENTIPEDE_
printFunction(cntxt->fdout, mb, 0, LIST_MAL_STMT);
#endif
diff --git a/monetdb5/optimizer/opt_octopus.c b/monetdb5/optimizer/opt_octopus.c
--- a/monetdb5/optimizer/opt_octopus.c
+++ b/monetdb5/optimizer/opt_octopus.c
@@ -270,7 +270,7 @@ isAView(InstrPtr p)
static int
OCTinitcode(Client cntxt, MalBlkPtr mb){
InstrPtr p;
- str s;
+ str s, msg= MAL_SUCCEED;
str l = NULL;
(void) cntxt;
@@ -278,13 +278,17 @@ OCTinitcode(Client cntxt, MalBlkPtr mb){
p = newStmt(mb, remoteRef,connectRef);
s = GDKgetenv("merovingian_uri");
if (s == NULL) /* aparently not under Merovingian control, fall back to
local only */
- SABAOTHgetLocalConnection(&l);
- p= pushStr(mb,p, s == NULL ? l : s);
- p= pushStr(mb,p,"monetdb");
- p= pushStr(mb,p,"monetdb");
- p= pushStr(mb,p,"msql");
+ msg = SABAOTHgetLocalConnection(&l);
+ if( msg == MAL_SUCCEED){
+ p= pushStr(mb,p, s == NULL ? l : s);
+ p= pushStr(mb,p,"monetdb");
+ p= pushStr(mb,p,"monetdb");
+ p= pushStr(mb,p,"msql");
+ }
if (l)
GDKfree(l);
+ if ( msg)
+ GDKfree(msg);
return getArg(p,0);
}
@@ -982,6 +986,7 @@ OPToctopusImplementation(Client cntxt, M
str tnm, tblname = NULL;
char rname[BUFSIZ];
MalBlkPtr *tentacle = NULL;
+ Module mod;
(void) stk;
@@ -992,7 +997,7 @@ OPToctopusImplementation(Client cntxt, M
/* printFunction(cntxt->fdout, mb, 0,
LIST_MAL_STMT | LIST_MAL_TYPE | LIST_MAPI);*/
}
- (void) fixModule(cntxt->nspace,octopusRef);
+ mod= fixModule(cntxt->nspace,octopusRef);
old = mb->stmt;
limit = mb->stop;
@@ -1307,6 +1312,8 @@ cleanup:
octCluster = NULL;
octClCnt = 0;
}
+ if(mod)
+ GDKfree(mod);
return actions;
}
@@ -1337,7 +1344,8 @@ OPTlegAdviceInternal(MalBlkPtr mb, MalSt
b = BBPquickdesc(bid, FALSE);
if ( b != NULL && BATcount(b) > 0 )
return (int) BATcount(b);
- }
+ } else
+ GDKfree(msg);
/* return GDKnr_threads;*/
}
return -1;
diff --git a/monetdb5/optimizer/opt_pushselect.c
b/monetdb5/optimizer/opt_pushselect.c
--- a/monetdb5/optimizer/opt_pushselect.c
+++ b/monetdb5/optimizer/opt_pushselect.c
@@ -119,7 +119,7 @@ OPTpushselectImplementation(Client cntxt
{
int i, j, limit, slimit, actions=0, *vars, push_down_delta = 0, nr_topn
= 0, nr_likes = 0;
InstrPtr p, *old;
- subselect_t subselects;
+ subselect_t subselects={0};
subselects.nr = 0;
if( mb->errors)
diff --git a/monetdb5/scheduler/run_octopus.c b/monetdb5/scheduler/run_octopus.c
--- a/monetdb5/scheduler/run_octopus.c
+++ b/monetdb5/scheduler/run_octopus.c
@@ -233,7 +233,7 @@ OCTOPUSdiscover(Client cntxt){
if ( !nrworkers ) {
/* there is a last resort, local execution */
- SABAOTHgetLocalConnection(&s);
+ msg = SABAOTHgetLocalConnection(&s);
workers[nrworkers].pnum = OCTOPUSgetPeer(s); /*ref to peers
registry*/
snprintf(buf,BUFSIZ,"worker_%d",nrworkers);
@@ -256,7 +256,7 @@ OCTOPUSdiscover(Client cntxt){
if ( !peers[i].active )
OCTOPUScleanFunReg(i);
- return MAL_SUCCEED;
+ return msg;
}
/*
@@ -651,7 +651,9 @@ OCTOPUSdisconnect(Client cntxt)
str msg = MAL_SUCCEED;
for ( i=0; i< nrpeers; i++)
- if ( peers[i].active && peers[i].conn != NULL ) {
+ if ( peers[i].active && peers[i].conn != NULL ) {
+ if( msg )
+ GDKfree(msg);
msg = RMTdisconnect(cntxt,&peers[i].conn);
GDKfree(peers[i].conn);
peers[i].conn = NULL;
diff --git a/monetdb5/scheduler/srvpool.c b/monetdb5/scheduler/srvpool.c
--- a/monetdb5/scheduler/srvpool.c
+++ b/monetdb5/scheduler/srvpool.c
@@ -187,6 +187,8 @@ SRVPOOLdisconnect(Client cntxt)
for ( i=0; i< srvtop; i++)
if ( servers[i].conn != NULL ) {
+ if( msg)
+ GDKfree(msg);
msg = RMTdisconnect(cntxt,&servers[i].conn);
GDKfree(servers[i].conn);
servers[i].conn = NULL;
@@ -321,13 +323,15 @@ SRVPOOLdiscover(Client cntxt)
while (srvtop < srvbaseline) {
/* there is a last resort, use local execution */
/* make sure you have enough connections */
- SABAOTHgetLocalConnection(&s);
-
- j = SRVPOOLnewServer(s); /*ref to servers registry*/
- msg = RMTconnectScen(&conn, &servers[j].uri, &servers[j].usr,
&servers[j].pwd, &scen);
+ msg = SABAOTHgetLocalConnection(&s);
+ if( msg == MAL_SUCCEED){
+ j = SRVPOOLnewServer(s); /*ref to servers registry*/
+ msg = RMTconnectScen(&conn, &servers[j].uri,
&servers[j].usr, &servers[j].pwd, &scen);
+ }
if ( msg == MAL_SUCCEED )
servers[j].conn = GDKstrdup(conn);
- else GDKfree(msg);
+ else
+ GDKfree(msg);
#ifdef DEBUG_RUN_SRVPOOL
mnstr_printf(cntxt->fdout,"#Worker site %d connection %s %s\n",
j, servers[j].conn, s);
#endif
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1734,7 +1734,7 @@ mvc_append_wrap(Client cntxt, MalBlkPtr
return msg;
if ((msg = checkSQLContext(cntxt)) != NULL)
return msg;
- if (tpe > TYPE_any)
+ if (tpe > GDKatomcnt)
tpe = TYPE_bat;
if (tpe == TYPE_bat && (ins = BATdescriptor(*(int *) ins)) == NULL)
throw(SQL, "sql.append", "Cannot access descriptor");
@@ -4619,7 +4619,8 @@ RAstatement(Client cntxt, MalBlkPtr mb,
resetMalBlk(cntxt->curprg->def, oldstop);
freeVariables(cntxt, cntxt->curprg->def, NULL, oldvtop);
}
- assert(cntxt->glb == 0 || cntxt->glb == oldglb); /*
detect leak */
+ if( !(cntxt->glb == 0 || cntxt->glb == oldglb))
+ msg= createException(MAL,"sql","global stack leakage");
/* detect leak */
cntxt->glb = oldglb;
}
return msg;
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -1319,8 +1319,10 @@ SQLstatementIntern(Client c, str *expr,
msg = SQLinitEnvironment(c);
sql = (backend *) c->sqlcontext;
}
- if (msg)
+ if (msg){
+ GDKfree(msg);
throw(SQL, "SQLstatement", "Catalogue not available");
+ }
initSQLreferences();
m = sql->mvc;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list