Changeset: f1f877b62dcd for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f1f877b62dcd Modified Files: monetdb5/extras/sphinx/sphinx.c monetdb5/modules/atoms/url.c monetdb5/modules/mal/mal_io.c monetdb5/modules/mal/remote.c monetdb5/modules/mal/sysmon.c monetdb5/optimizer/opt_cluster.c monetdb5/optimizer/opt_multiplex.c monetdb5/optimizer/opt_remap.c sql/backends/monet5/sql_optimizer.c sql/backends/monet5/sql_scenario.c sql/backends/monet5/sql_statistics.c sql/backends/monet5/vaults/fits.c Branch: Jan2014 Log Message:
Fixes of problems found by Coverity. diffs (237 lines): diff --git a/monetdb5/extras/sphinx/sphinx.c b/monetdb5/extras/sphinx/sphinx.c --- a/monetdb5/extras/sphinx/sphinx.c +++ b/monetdb5/extras/sphinx/sphinx.c @@ -78,11 +78,14 @@ sphinx_searchIndexLimit(BAT **ret, /* pu str SPHINXsearchIndexLimit(int *ret, str *query, str *index, int *limit) { - BAT *b = NULL; + BAT *b; str msg = sphinx_searchIndexLimit(&b, *query, *index, *limit); - if (!b) + if (msg) { + GDKfree(msg); throw(MAL, "sphinx.searchIndex", "Cannot create Sphinx object"); + } + assert(b != NULL); *ret = b->batCacheid; BBPkeepref(*ret); return msg; diff --git a/monetdb5/modules/atoms/url.c b/monetdb5/modules/atoms/url.c --- a/monetdb5/modules/atoms/url.c +++ b/monetdb5/modules/atoms/url.c @@ -427,8 +427,10 @@ URLgetContent(str *retval, str *Str1) (void)memcpy(retbuf + rlen, buf, len); rlen += len; } - if (len < 0) + if (len < 0) { + GDKfree(retbuf); throw(MAL, "url.getContent", "read error"); + } retbuf[rlen] = '\0'; *retval = retbuf; diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c --- a/monetdb5/modules/mal/mal_io.c +++ b/monetdb5/modules/mal/mal_io.c @@ -873,6 +873,7 @@ IOimport(int *ret, int *bid, str *fnme) throw(MAL, "io.import", "insert failed"); } +#if 0 /* why do this? any measured effects? */ /* * Unmap already parsed memory, to keep the memory usage low. */ @@ -883,6 +884,7 @@ IOimport(int *ret, int *bid, str *fnme) base += MAXBUF; } #endif +#endif } /* Cleanup and exit. Return the filled BAT. */ if (h) diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c --- a/monetdb5/modules/mal/remote.c +++ b/monetdb5/modules/mal/remote.c @@ -517,7 +517,9 @@ str RMTget(Client cntxt, MalBlkPtr mb, M qbuf, tmp); #endif MT_lock_unset(&c->lock, "remote.get"); - throw(MAL, "remote.get", "%s", tmp); + val = createException(MAL, "remote.get", "%s", tmp); + GDKfree(tmp); + return val; } h = getHeadType(rtype); t = getTailType(rtype); diff --git a/monetdb5/modules/mal/sysmon.c b/monetdb5/modules/mal/sysmon.c --- a/monetdb5/modules/mal/sysmon.c +++ b/monetdb5/modules/mal/sysmon.c @@ -43,7 +43,8 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb, int i, prog; str usr; timestamp ts, tsn; - + str msg; + (void) cntxt; (void) mb; tag = BATnew(TYPE_void, TYPE_lng, 256); @@ -108,8 +109,12 @@ SYSMONqueue(Client cntxt, MalBlkPtr mb, /* convert number of seconds into a timestamp */ now = QRYqueue[i].start * 1000; - (void) MTIMEunix_epoch(&ts); - (void) MTIMEtimestamp_add(&tsn, &ts, &now); + msg = MTIMEunix_epoch(&ts); + if (msg) + return msg; + msg = MTIMEtimestamp_add(&tsn, &ts, &now); + if (msg) + return msg; BUNappend(started, &tsn, FALSE); if ( QRYqueue[i].mb->runtime == 0) diff --git a/monetdb5/optimizer/opt_cluster.c b/monetdb5/optimizer/opt_cluster.c --- a/monetdb5/optimizer/opt_cluster.c +++ b/monetdb5/optimizer/opt_cluster.c @@ -655,6 +655,8 @@ cluster_join(MalBlkPtr mb) q->argc == 3 && ((state_mr == JOIN_MARK && mr == getArg(q,2)) || (state_rmr == JOIN_MARK && rmr == getArg(q,2)))) { + GDKfree(join); + GDKfree(prj); return 0; } else if (getModuleId(q) == algebraRef && getFunctionId(q) == leftjoinRef && diff --git a/monetdb5/optimizer/opt_multiplex.c b/monetdb5/optimizer/opt_multiplex.c --- a/monetdb5/optimizer/opt_multiplex.c +++ b/monetdb5/optimizer/opt_multiplex.c @@ -249,5 +249,6 @@ OPTmultiplexImplementation(Client cntxt, if (mb->errors){ /* rollback */ } + GDKfree(msg); return mb->errors? 0: actions; } diff --git a/monetdb5/optimizer/opt_remap.c b/monetdb5/optimizer/opt_remap.c --- a/monetdb5/optimizer/opt_remap.c +++ b/monetdb5/optimizer/opt_remap.c @@ -138,8 +138,10 @@ OPTmultiplexInline(Client cntxt, MalBlkP } upgrade = (bit*) GDKzalloc(sizeof(bit)*mq->vtop); - if( upgrade == NULL) + if( upgrade == NULL) { + freeMalBlk(mq); return 0; + } setVarType(mq, 0,newBatType(TYPE_oid, getArgType(mb,p,0))); clrVarFixed(mq,getArg(getInstrPtr(mq,0),0)); /* for typing */ diff --git a/sql/backends/monet5/sql_optimizer.c b/sql/backends/monet5/sql_optimizer.c --- a/sql/backends/monet5/sql_optimizer.c +++ b/sql/backends/monet5/sql_optimizer.c @@ -90,6 +90,7 @@ SQLgetStatistics(Client cntxt, mvc *m, M int oldtop, i, actions = 0, size = 0; lng clk = GDKusec(); sql_trans *tr = m->session->tr; + str msg; old = mb->stmt; oldtop = mb->stop; @@ -187,7 +188,9 @@ SQLgetStatistics(Client cntxt, mvc *m, M } } GDKfree(old); - optimizerCheck(cntxt, mb, "optimizer.SQLgetstatistics", actions, GDKusec() - clk, 0); + msg = optimizerCheck(cntxt, mb, "optimizer.SQLgetstatistics", actions, GDKusec() - clk, 0); + if (msg) /* what to do with an error? */ + GDKfree(msg); } str @@ -207,11 +210,14 @@ addOptimizers(Client c, MalBlkPtr mb, ch int i; InstrPtr q; backend *be; + str msg; be = (backend *) c->sqlcontext; assert(be && be->mvc); /* SQL clients should always have their state set */ - addOptimizerPipe(c, mb, pipe ? pipe : "default_pipe"); + msg = addOptimizerPipe(c, mb, pipe ? pipe : "default_pipe"); + if (msg) + GDKfree(msg); /* what to do with an error? */ /* point queries do not require mitosis and dataflow */ if (be->mvc->point_query) for (i = mb->stop - 1; i > 0; i--) { @@ -267,6 +273,7 @@ addQueryToCache(Client c) msg = optimizeMALBlock(c, mb); if (msg != MAL_SUCCEED) { showScriptException(c->fdout, mb, 0, MAL, "%s", msg); + GDKfree(msg); return; } 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 @@ -83,11 +83,15 @@ monet5_freestack(int clientid, backend_s static void monet5_freecode(int clientid, backend_code code, backend_stack stk, int nr, char *name) { + str msg; + (void) code; (void) stk; (void) nr; (void) clientid; - SQLCacheRemove(MCgetClient(clientid), name); + msg = SQLCacheRemove(MCgetClient(clientid), name); + if (msg) + GDKfree(msg); /* do something with error? */ #ifdef _SQL_SCENARIO_DEBUG mnstr_printf(GDKout, "#monet5_free:%d\n", nr); diff --git a/sql/backends/monet5/sql_statistics.c b/sql/backends/monet5/sql_statistics.c --- a/sql/backends/monet5/sql_statistics.c +++ b/sql/backends/monet5/sql_statistics.c @@ -60,8 +60,13 @@ sql_analyze(Client cntxt, MalBlkPtr mb, query = (char *) GDKzalloc(8192); maxval = (char *) GDKzalloc(8192); minval = (char *) GDKzalloc(8192); - if (!(dquery && query && maxval && minval)) + if (!(dquery && query && maxval && minval)) { + GDKfree(dquery); + GDKfree(query); + GDKfree(maxval); + GDKfree(minval); throw(SQL, "analyze", MAL_MALLOC_FAIL); + } switch (argc) { case 4: diff --git a/sql/backends/monet5/vaults/fits.c b/sql/backends/monet5/vaults/fits.c --- a/sql/backends/monet5/vaults/fits.c +++ b/sql/backends/monet5/vaults/fits.c @@ -622,7 +622,7 @@ str FITSdirpat(Client cntxt, MalBlkPtr m /* mnstr_printf(GDKout,"#fulldir: %s \nSize: %lu\n",fulldirectory, globbuf.gl_pathc);*/ if (globbuf.gl_pathc == 0) - msg = createException(MAL, "listdir", "Couldn't open the directory or there are no files that match the pattern"); + throw(MAL, "listdir", "Couldn't open the directory or there are no files that match the pattern"); for (j = 0; j < globbuf.gl_pathc; j++) { char stmt[BUFSIZ]; @@ -636,6 +636,7 @@ str FITSdirpat(Client cntxt, MalBlkPtr m snprintf(stmt, BUFSIZ, ATTACHDIR, fname); msg = SQLstatementIntern(cntxt, &s, "fits.listofdirpat", TRUE, FALSE); fits_close_file(fptr, &status); + break; } } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list