Changeset: 5a99fc082e0b for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5a99fc082e0b Modified Files: monetdb5/mal/mal_profiler.c monetdb5/modules/atoms/str.c monetdb5/modules/mal/mat.c Branch: Jan2014 Log Message:
Coverity fixes diffs (121 lines): diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -771,7 +771,7 @@ setFilter(Module cntxt, str mod, str fcn profileAll = strcmp(mod, "*") == 0 && strcmp(fcn, "*") == 0; MT_lock_set(&mal_profileLock, "setFilter"); - if (mod && fcn && topFilter < 32) { + if (topFilter < 32) { modFilter[topFilter] = putName(mod, strlen(mod)); fcnFilter[topFilter++] = putName(fcn, strlen(fcn)); } diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c --- a/monetdb5/modules/atoms/str.c +++ b/monetdb5/modules/atoms/str.c @@ -1702,10 +1702,11 @@ strSubstitute(str *res, str s, str src, if (repeat && ldst > lsrc && lsrc) { n = (ldst * l) / lsrc; /* max length */ } - buf = *res = (str) GDKmalloc(n); + buf = *res = (str) GDKzalloc(n); end = buf + l; fnd = buf; - strcpy(buf, s); + if( s) + strcpy(buf, s); if (!lsrc) return GDK_SUCCEED; do { diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c --- a/monetdb5/modules/mal/mat.c +++ b/monetdb5/modules/mal/mat.c @@ -181,15 +181,11 @@ MATpackIncrement(Client cntxt, MalBlkPtr if (BATcount(b) == 0) BATseqbase(BATmirror(b), bb->T->seq); BATappend(b,bb,FALSE); - } else { - BBPreleaseref(b->batCacheid); - throw(MAL, "mat.pack", RUNTIME_OBJECT_MISSING); } assert(!b->H->nil || !b->H->nonil); assert(!b->T->nil || !b->T->nonil); BBPkeepref(*ret = b->batCacheid); BBPreleaseref(bb->batCacheid); - BBPreleaseref(b->batCacheid); } return MAL_SUCCEED; } @@ -269,9 +265,6 @@ MATpackSliceInternal(MalBlkPtr mb, MalSt */ if (lst <= cap + c) { b = BATdescriptor(bid); - if ( b == NULL){ - throw(MAL,"mat.packSlice", RUNTIME_OBJECT_MISSING); - } bn = BATslice(b, fst - cap, lst - cap); BBPunfix(b->batCacheid); BBPkeepref(*ret = bn->batCacheid); @@ -356,7 +349,7 @@ MATpack2Internal(MalStkPtr stk, InstrPtr } bn = BATextend(bn, cap); if( bn == NULL) - throw(MAL, "mat.pack", MAL_MALLOC_FAIL); + throw(MAL, "mat.pack", RUNTIME_OBJECT_MISSING); for( i = 2; i < p->argc; i++){ b= BATdescriptor(stk->stk[getArg(p,i)].val.ival); if( b == NULL){ @@ -494,12 +487,8 @@ MATmergepack(Client cntxt, MalBlkPtr mb, } bn = BATnew(TYPE_void, TYPE_oid, cap); - if (bn == NULL){ - GDKfree(bats); - GDKfree(o_src); - GDKfree(o_end); + if (bn == NULL) throw(MAL, "mat.pack", MAL_MALLOC_FAIL); - } if ( cap == 0){ BATseqbase(bn, 0); BATseqbase(BATmirror(bn), 0); @@ -821,9 +810,8 @@ MATproject_var( BAT *map, BAT **bats, in res->T->shift = bats[j]->T->shift; BBPshare(bats[j]->T->vheap->parentid); } - } else { + } else res = MATproject_any( map, bats, len ); - } return res; } @@ -858,7 +846,7 @@ MATproject_( BAT *map, BAT **bats, int l } else { res = MATproject_any(map, bats, len); } - if( res) { + if(res){ res->tsorted = 0; res->trevsorted = 0; res->T->nonil = MATnonil(bats, len); @@ -878,6 +866,8 @@ MATproject(Client cntxt, MalBlkPtr mb, M int i, len = pci->argc-2, sorted = 1; (void) cntxt; (void) mb; (void) stk; + if( bats == NULL) + throw(SQL, "mat.project",MAL_MALLOC_FAIL); map = BATdescriptor(map_id); if (!map) goto error; @@ -1616,9 +1606,8 @@ MATsort(Client cntxt, MalBlkPtr mb, MalS int i, len = pci->argc-2; (void) cntxt; (void) mb; (void) stk; - if( bats ==NULL) + if( bats == NULL) throw(SQL, "mat.sortTail",MAL_MALLOC_FAIL); - for (i=2; i<pci->argc; i++) { bat id = *(bat*) getArgReference(stk,pci,i); bats[i-2] = BATdescriptor(id); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list