Changeset: 9f5a19c61bdb for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9f5a19c61bdb Modified Files: monetdb5/modules/atoms/mtime.c monetdb5/modules/kernel/group.mx monetdb5/modules/mal/pcre.c Branch: default Log Message:
Added some checks that functions succeed. diffs (205 lines): diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -2850,7 +2850,10 @@ MTIMEdate_extract_year_bulk(int *ret, in BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdate_extract_year(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.year", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -2885,7 +2888,10 @@ MTIMEdate_extract_month_bulk(int *ret, i BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdate_extract_month(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.month", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -2920,7 +2926,10 @@ MTIMEdate_extract_day_bulk(int *ret, int BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdate_extract_day(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.day", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -2955,7 +2964,10 @@ MTIMEdaytime_extract_hours_bulk(int *ret BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdaytime_extract_hours(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.hours", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -2990,7 +3002,10 @@ MTIMEdaytime_extract_minutes_bulk(int *r BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdaytime_extract_minutes(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.minutes", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -3025,7 +3040,10 @@ MTIMEdaytime_extract_seconds_bulk(int *r BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdaytime_extract_seconds(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.seconds", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -3060,7 +3078,10 @@ MTIMEdaytime_extract_sql_seconds_bulk(in BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdaytime_extract_sql_seconds(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.sql_seconds", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; @@ -3095,7 +3116,10 @@ MTIMEdaytime_extract_milliseconds_bulk(i BATloop(b, p, q) { d = *(date *) BUNtail(bi, p); MTIMEdaytime_extract_milliseconds(&v, &d); - BUNfastins(bn, BUNhead(bi, p), &v); + if (BUNfastins(bn, BUNhead(bi, p), &v) == NULL) { + BBPunfix(bn->batCacheid); + throw(MAL, "batmtime.milliseconds", "inserting value failed"); + } } bn->H->nonil = b->H->nonil; bn->hsorted = b->hsorted; diff --git a/monetdb5/modules/kernel/group.mx b/monetdb5/modules/kernel/group.mx --- a/monetdb5/modules/kernel/group.mx +++ b/monetdb5/modules/kernel/group.mx @@ -1705,7 +1705,10 @@ str GRPslidingsum_@1(int *retval, int *b BATloop(b, p, q) { sum += *(@1*) BUNtail(bi,p); if (--i == 0){ - BUNfastins(bn, &o, &sum); + if (BUNfastins(bn, &o, &sum) == NULL) { + BBPreclaim(bn); + throw(MAL, "group.sum", OPERATION_FAILED); + } /* slide here */ if (*size != *shift ){ p -= (*size-*shift); @@ -1714,8 +1717,10 @@ str GRPslidingsum_@1(int *retval, int *b sum =0; } } - if(i != *size) - BUNfastins(bn, &o, &sum); + if(i != *size && BUNfastins(bn, &o, &sum) == NULL) { + BBPreclaim(bn); + throw(MAL, "group.sum", OPERATION_FAILED); + } bn->tsorted = bn->hsorted = 0; bn->trevsorted = bn->hrevsorted = 0; 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 @@ -231,20 +231,28 @@ re_uselect(RE *pattern, BAT *strs, int i r = BATnew(TYPE_oid, TYPE_void, BATcount(strs)); else r = BATnew(strs->htype, TYPE_void, BATcount(strs)); + if (r == NULL) + return NULL; if (ignore) { BATloop(strs, p, q) { str s = BUNtail(strsi, p); - if (re_match_ignore(s, pattern)) - BUNfastins(r, BUNhead(strsi, p), NULL); + if (re_match_ignore(s, pattern) && + BUNfastins(r, BUNhead(strsi, p), NULL) == NULL) { + BBPreclaim(r); + return NULL; + } } } else { BATloop(strs, p, q) { str s = BUNtail(strsi, p); - if (re_match_no_ignore(s, pattern)) - BUNfastins(r, BUNhead(strsi, p), NULL); + if (re_match_no_ignore(s, pattern) && + BUNfastins(r, BUNhead(strsi, p), NULL) == NULL) { + BBPreclaim(r); + return NULL; + } } } r->H->nonil = strs->H->nonil; @@ -270,6 +278,8 @@ re_select(RE *pattern, BAT *strs, int ig r = BATnew(TYPE_oid, TYPE_str, BATcount(strs)); else r = BATnew(strs->htype, TYPE_str, BATcount(strs)); + if (r == NULL) + return NULL; if (ignore) { BATloop(strs, p, q) { @@ -559,6 +569,8 @@ pcre_uselect(BAT **res, str pattern, BAT r = BATnew(TYPE_oid, TYPE_void, BATcount(strs)); else r = BATnew(strs->htype, TYPE_void, BATcount(strs)); + if (r == NULL) + throw(MAL, "pcre_uselect", MAL_MALLOC_FAIL); if ((re = pcre_compile(pattern, options, &err_p, &errpos, NULL)) == NULL) { throw(MAL, "pcre_uselect", OPERATION_FAILED "pcre compile of pattern (%s) failed at %d with\n'%s'.", pattern, errpos, err_p); @@ -572,8 +584,10 @@ pcre_uselect(BAT **res, str pattern, BAT str s = BUNtail(strsi, p); int l = (int) strlen(s); - if (pcre_exec(re, pe, s, l, 0, 0, NULL, 0) >= 0) { - BUNfastins(r, BUNhead(strsi, p), NULL); + if (pcre_exec(re, pe, s, l, 0, 0, NULL, 0) >= 0 && + BUNfastins(r, BUNhead(strsi, p), NULL) == NULL) { + BBPreclaim(r); + throw(MAL, "pcre_uselect", OPERATION_FAILED); } } r->H->nonil = strs->H->nonil; @@ -1604,6 +1618,10 @@ PCRElike_pcre(int *ret, int *b, str *pat res = re_select(re, bp, ignore); re_destroy(re); + if (res == NULL) { + BBPreleaseref(bp->batCacheid); + throw(MAL, "pcre.like", OPERATION_FAILED); + } *ret = res->batCacheid; BBPkeepref(res->batCacheid); BBPreleaseref(bp->batCacheid); _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list