Changeset: 9c4769a6042f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9c4769a6042f
Modified Files:
        geom/monetdb5/geod.c
        geom/monetdb5/geom.c
        geom/monetdb5/geomBulk.c
Branch: Dec2023
Log Message:

Dead code; possible NULL dereference; possible memory leak.


diffs (109 lines):

diff --git a/geom/monetdb5/geod.c b/geom/monetdb5/geod.c
--- a/geom/monetdb5/geod.c
+++ b/geom/monetdb5/geod.c
@@ -1027,7 +1027,9 @@ filterJoinGeomGeomDoubleToBit(bat *lres_
        BUN est;
 
        //get the input BATs
-       if ((l = BATdescriptor(*l_id)) == NULL || (r = BATdescriptor(*r_id)) == 
NULL) {
+       l = BATdescriptor(*l_id);
+       r = BATdescriptor(*r_id);
+       if (l == NULL || r == NULL) {
                if (l)
                        BBPunfix(l->batCacheid);
                if (r)
@@ -1170,8 +1172,6 @@ wkbDWithinGeographicJoin(bat *lres_id, b
        BAT *d = NULL;
        //Get the distance BAT and get the double value
        if ((d = BATdescriptor(*d_id)) == NULL) {
-               if (d)
-                       BBPunfix(d->batCacheid);
                throw(MAL, "geom.wkbDWithinGeographicJoin", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
        }
        if (BATcount(d) == 1) {
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -163,12 +163,6 @@ wkbCollectAggrSubGroupedCand(bat *outid,
                                                                
GDKfree(unions[i]);
                                                        GDKfree(unions);
                                                }
-                                               if (unionGroup) {
-                                                       for (BUN i = 0; i < 
geomCount; i++)
-                                                               if 
(unionGroup[i])
-                                                                       
GEOSGeom_destroy(unionGroup[i]);
-                                                       GDKfree(unionGroup);
-                                               }
                                                goto free;
                                        }
                                }
@@ -241,8 +235,6 @@ wkbCollectAggr (wkb **out, const bat *bi
 
        if ((b = BATdescriptor(*bid)) == NULL) {
                msg = createException(MAL, "geom.Collect", 
RUNTIME_OBJECT_MISSING);
-               if (b)
-                       BBPunfix(b->batCacheid);
                return msg;
        }
 
@@ -3572,6 +3564,10 @@ wkbMakeLineAggrSubGroupedCand(bat *outid
                        if (lastGrp != (oid)-1) {
                                msg = wkbMakeLineAggrArray(&lines[lastGrp], 
lineGroup, position);
                                position = 0;
+                               if (msg != MAL_SUCCEED) {
+                                       GDKfree(lineGroup);
+                                       goto free;
+                               }
                        }
                        lastGrp = grp;
                }
@@ -3579,6 +3575,8 @@ wkbMakeLineAggrSubGroupedCand(bat *outid
        }
        msg = wkbMakeLineAggrArray(&lines[lastGrp], lineGroup, position);
        GDKfree(lineGroup);
+       if (msg != MAL_SUCCEED)
+               goto free;
 
        if (BUNappendmulti(out, lines, ngrp, false) != GDK_SUCCEED) {
                msg = createException(MAL, "geom.Union", SQLSTATE(38000) 
"BUNappend operation failed");
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -787,15 +787,6 @@ wkbTransform_bat_cand(bat *outBAT_id, ba
                oid p = (canditer_next(&ci) - inBAT->hseqbase);
                geomWKB = (wkb *) BUNtvar(inBAT_iter, p);
 
-               if (geomWKB == NULL) {
-                       bat_iterator_end(&inBAT_iter);
-                       BBPunfix(inBAT->batCacheid);
-                       BBPunfix(outBAT->batCacheid);
-                       if (s)
-                               BBPunfix(s->batCacheid);
-                       throw(MAL, "batgeom.Transform", SQLSTATE(38000) "One of 
the wkb geometries is null");
-               }
-
                /* get the geosGeometry from the wkb */
                geosGeometry = wkb2geos(geomWKB);
                /* get the type of the geometry */
@@ -930,16 +921,12 @@ wkbDistanceGeographic_bat_cand(bat *out_
 bailout:
        bat_iterator_end(&a_iter);
        bat_iterator_end(&b_iter);
-       if (s1)
-               BBPunfix(s1->batCacheid);
-       if (s2)
-               BBPunfix(s2->batCacheid);
+       BBPreclaim(s1);
+       BBPreclaim(s2);
 clean:
-       if (a)
-               BBPunfix(a->batCacheid);
-       if (b)
-               BBPunfix(b->batCacheid);
-       BBPunfix(out->batCacheid);
+       BBPreclaim(a);
+       BBPreclaim(b);
+       BBPreclaim(out);
        return msg;
 }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to