Changeset: 0cbe530ed756 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0cbe530ed756
Modified Files:
        monetdb5/modules/mal/pcre.c
Branch: Jan2014
Log Message:

Fixing Coverity complaints


diffs (47 lines):

diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1798,20 +1798,40 @@ PCRElike_join(int *l, int *r, int *b, in
 {
        BUN p;
        BAT *B = BATdescriptor(*b), *Bpat = BATdescriptor(*pat), *L, *R;
-       BAT *tr, *x, *j = BATnew(TYPE_oid, TYPE_oid, BATcount(B) * 
BATcount(Bpat));
+       BAT *tr, *x, *j;
        BATiter pati = bat_iterator(Bpat);
 
+       if( B == NULL || Bpat == NULL){
+               if( B) BBPreleaseref(B->batCacheid);
+               if( Bpat) BBPreleaseref(Bpat->batCacheid);
+               throw(MAL,"pcre.like", MAL_MALLOC_FAIL);
+       }
+       j = BATnew(TYPE_oid, TYPE_oid, BATcount(B) * BATcount(Bpat));
+       if( j == NULL){
+               if( B) BBPreleaseref(B->batCacheid);
+               if( Bpat) BBPreleaseref(Bpat->batCacheid);
+               throw(MAL,"pcre.like", MAL_MALLOC_FAIL);
+       }
+
        for(p = 0; p < BATcount(Bpat); p++) {
                char *ppat = (str)BUNtail(pati, p);
                int r;
                str err;
 
                if (case_sensitive) {
-                       if ((err = PCRElike_uselect_pcre( &r, b, &ppat, esc)) 
!= MAL_SUCCEED)
+                       if ((err = PCRElike_uselect_pcre( &r, b, &ppat, esc)) 
!= MAL_SUCCEED){
+                               BBPunfix(j->batCacheid);
+                               BBPreleaseref(B->batCacheid);
+                               BBPreleaseref(Bpat->batCacheid);
                                return err;
+                       }
                } else {
-                       if ((err = PCREilike_uselect_pcre( &r, b, &ppat, esc)) 
!= MAL_SUCCEED)
+                       if ((err = PCREilike_uselect_pcre( &r, b, &ppat, esc)) 
!= MAL_SUCCEED){
+                               BBPunfix(j->batCacheid);
+                               BBPreleaseref(B->batCacheid);
+                               BBPreleaseref(Bpat->batCacheid);
                                return err;
+                       }
                }
 
                tr = BATdescriptor(r);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to