Changeset: 281c6d02902f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=281c6d02902f
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        clients/mapiclient/dotmonetdb.c
        clients/mapiclient/mclient.c
        common/stream/stream.c
        gdk/gdk_bat.c
        gdk/gdk_heap.c
        gdk/gdk_logger.c
        geom/monetdb5/geom.c
        geom/monetdb5/geom_upgrade.c
        monetdb5/extras/rapi/rapi.c
        monetdb5/mal/mal_builder.c
        monetdb5/mal/mal_client.c
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_exception.c
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_linker.c
        monetdb5/mal/mal_listing.c
        monetdb5/mal/mal_resolve.c
        monetdb5/mal/mal_runtime.c
        monetdb5/mal/mal_session.c
        monetdb5/mal/mal_type.c
        monetdb5/modules/atoms/batxml.c
        monetdb5/modules/atoms/blob.c
        monetdb5/modules/atoms/blob.h
        monetdb5/modules/atoms/color.c
        monetdb5/modules/atoms/identifier.c
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/streams.c
        monetdb5/modules/atoms/url.c
        monetdb5/modules/atoms/uuid.c
        monetdb5/modules/atoms/xml.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/mal_io.c
        monetdb5/modules/mal/mal_mapi.c
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/remote.c
        monetdb5/modules/mal/sysmon.c
        monetdb5/modules/mal/tablet.c
        monetdb5/modules/mal/tablet.h
        monetdb5/modules/mal/txtsim.c
        monetdb5/optimizer/opt_emptybind.c
        monetdb5/optimizer/opt_evaluate.c
        monetdb5/optimizer/opt_macro.c
        monetdb5/optimizer/opt_mergetable.c
        monetdb5/optimizer/opt_multiplex.c
        monetdb5/optimizer/opt_reorder.c
        monetdb5/optimizer/opt_support.c
        monetdb5/scheduler/run_adder.c
        sql/backends/monet5/UDF/pyapi/convert_loops.h
        sql/backends/monet5/generator/generator.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql.mal
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_gencode.c
        sql/backends/monet5/sql_optimizer.c
        sql/backends/monet5/sql_scenario.c
        sql/backends/monet5/sql_upgrades.c
        sql/backends/monet5/sql_user.c
        sql/backends/monet5/vaults/bam/bam_export.c
        sql/backends/monet5/vaults/bam/bam_globals.h
        sql/backends/monet5/vaults/bam/bam_wrapper.c
        sql/backends/monet5/vaults/shp/shp.c
        sql/common/sql_mem.c
        sql/common/sql_types.c
        sql/server/rel_optimizer.c
        sql/server/rel_psm.c
        sql/server/rel_updates.c
        sql/storage/store.c
        
sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart-0.Bug-3063.stable.out
        
sql/test/BugTracker-2012/Tests/table_functions_fail_after_restart-1.Bug-3063.stable.out
        
sql/test/BugTracker-2017/Tests/wrong_aggregation_count.Bug-6257.stable.out
        sql/test/Dependencies/Tests/Dependencies.stable.out
        sql/test/Dependencies/Tests/Dependencies.stable.out.int128
        sql/test/DropCascade/Tests/drop_columns_cascade.stable.out
        sql/test/DropCascade/Tests/drop_pkey_cascade.stable.out
        sql/test/Dump/Tests/dump.stable.out
        sql/test/Tests/keys.stable.out
        sql/test/Tests/systemfunctions.stable.out
        sql/test/Tests/systemfunctions.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/check.stable.out.int128
        sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/check.stable.out
        sql/test/emptydb-upgrade-chain/Tests/check.stable.out.32bit
        sql/test/emptydb-upgrade-chain/Tests/check.stable.out.int128
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/emptydb-upgrade-hge/Tests/check.stable.out.int128
        sql/test/emptydb-upgrade/Tests/check.stable.out
        sql/test/emptydb-upgrade/Tests/check.stable.out.32bit
        sql/test/emptydb-upgrade/Tests/check.stable.out.int128
        sql/test/emptydb/Tests/check.stable.out
        sql/test/emptydb/Tests/check.stable.out.32bit
        sql/test/emptydb/Tests/check.stable.out.int128
        sql/test/leaks/Tests/check1.stable.out
        sql/test/leaks/Tests/check1.stable.out.int128
        sql/test/leaks/Tests/check2.stable.out
        sql/test/leaks/Tests/check2.stable.out.int128
        sql/test/leaks/Tests/check3.stable.out
        sql/test/leaks/Tests/check3.stable.out.int128
        sql/test/leaks/Tests/check4.stable.out
        sql/test/leaks/Tests/check4.stable.out.int128
        sql/test/leaks/Tests/check5.stable.out
        sql/test/leaks/Tests/check5.stable.out.int128
        sql/test/pg_regress/Tests/float8.stable.out
        
sql/test/sys-schema/Tests/check_ForeignKey_referential_integrity.stable.out
        sql/test/testdb-upgrade-chain-hge/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade-chain/Tests/dump.stable.out.Windows
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out
        sql/test/testdb-upgrade-chain/Tests/upgrade.stable.out.int128
        sql/test/testdb-upgrade/Tests/dump.stable.out.Windows
        sql/test/testdb/Tests/testdb-dump.stable.out.Windows
        tools/merovingian/daemon/controlrunner.c
        tools/mserver/mserver5.c
Branch: timetrails
Log Message:

Merge with default


diffs (truncated from 7629 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -8317,7 +8317,7 @@ Ready.
 [ "sql",       "bind_idxbat",  "pattern sql.bind_idxbat(mvc:int, schema:str, 
table:str, index:str, access:int, part_nr:int, nr_parts:int):bat[:any_1] ",     
  "mvc_bind_idxbat_wrap;",        "Bind the 'schema.table.index' BAT with 
access kind:\n\t0 - base table\n\t1 - inserts\n\t2 - updates"   ]
 [ "sql",       "clear_table",  "pattern sql.clear_table(sname:str, 
tname:str):lng ",   "mvc_clear_table_wrap;",        "Clear the table 
sname.tname."  ]
 [ "sql",       "commit",       "pattern sql.commit():void ",   "SQLcommit;",   
"Trigger the commit operation for a MAL block"  ]
-[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int):bat[:any]... ", "mvc_import_table_wrap;",       "Import a table from 
bstream s with the \n\tgiven tuple and seperators (sep/rsep)"      ]
+[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int, fwf:str):bat[:any]... ",        "mvc_import_table_wrap;",       
"Import a table from bstream s with the \n\tgiven tuple and seperators 
(sep/rsep)"      ]
 [ "sql",       "copy_rejects", "pattern sql.copy_rejects() (rowid:bat[:lng], 
fldid:bat[:int], msg:bat[:str], inp:bat[:str]) ", "COPYrejects;", ""      ]
 [ "sql",       "copy_rejects_clear",   "pattern sql.copy_rejects_clear():void 
",       "COPYrejects_clear;",   ""      ]
 [ "sql",       "create_func_upgrade_oct2014",  "pattern 
sql.create_func_upgrade_oct2014(sname:str, f:str):int ",       
"UPGcreate_func;",      "Create the function described by f, needed for the 
Oct2014 upgrade"    ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -10697,7 +10697,7 @@ Ready.
 [ "sql",       "bind_idxbat",  "pattern sql.bind_idxbat(mvc:int, schema:str, 
table:str, index:str, access:int, part_nr:int, nr_parts:int):bat[:any_1] ",     
  "mvc_bind_idxbat_wrap;",        "Bind the 'schema.table.index' BAT with 
access kind:\n\t0 - base table\n\t1 - inserts\n\t2 - updates"   ]
 [ "sql",       "clear_table",  "pattern sql.clear_table(sname:str, 
tname:str):lng ",   "mvc_clear_table_wrap;",        "Clear the table 
sname.tname."  ]
 [ "sql",       "commit",       "pattern sql.commit():void ",   "SQLcommit;",   
"Trigger the commit operation for a MAL block"  ]
-[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int):bat[:any]... ", "mvc_import_table_wrap;",       "Import a table from 
bstream s with the \n\tgiven tuple and seperators (sep/rsep)"      ]
+[ "sql",       "copy_from",    "pattern sql.copy_from(t:ptr, sep:str, 
rsep:str, ssep:str, ns:str, fname:str, nr:lng, offset:lng, locked:int, 
best:int, fwf:str):bat[:any]... ",        "mvc_import_table_wrap;",       
"Import a table from bstream s with the \n\tgiven tuple and seperators 
(sep/rsep)"      ]
 [ "sql",       "copy_rejects", "pattern sql.copy_rejects() (rowid:bat[:lng], 
fldid:bat[:int], msg:bat[:str], inp:bat[:str]) ", "COPYrejects;", ""      ]
 [ "sql",       "copy_rejects_clear",   "pattern sql.copy_rejects_clear():void 
",       "COPYrejects_clear;",   ""      ]
 [ "sql",       "create_func_upgrade_oct2014",  "pattern 
sql.create_func_upgrade_oct2014(sname:str, f:str):int ",       
"UPGcreate_func;",      "Create the function described by f, needed for the 
Oct2014 upgrade"    ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1704,7 +1704,7 @@ str SERVERstop(void *ret);
 str SERVERsuspend(void *ret);
 str SERVERtrace(void *ret, int *mid, int *flag);
 int SQLBLOBfromstr(char *instr, int *l, blob **val);
-int SQLBLOBtostr(str *tostr, int *l, blob *pin);
+int SQLBLOBtostr(str *tostr, int *l, const blob *pin);
 BUN SQLload_file(Client cntxt, Tablet *as, bstream *b, stream *out, char 
*csep, char *rsep, char quote, lng skip, lng maxrow, int best);
 str STRBytes(int *res, const str *arg1);
 str STRConcat(str *res, const str *val1, const str *val2);
@@ -1802,7 +1802,6 @@ str SYSmem_usage(bat *ret, bat *ret2, co
 str SYSsetmem_maxsize(void *ret, const lng *num);
 str SYSsetvm_maxsize(void *ret, const lng *num);
 str SYSvm_usage(bat *ret, bat *ret2, const lng *minsize);
-void *TABLETadt_frStr(Column *c, int type, char *s, char *e, char quote);
 int TABLETadt_toStr(void *extra, char **buf, int *len, int type, ptr a);
 str TABLETcollect(BAT **bats, Tablet *as);
 str TABLETcollect_parts(BAT **bats, Tablet *as, BUN offset);
@@ -2520,8 +2519,6 @@ str sortRef;
 str sortReverseRef;
 str soundex_impl(str *res, str *Name);
 str sqlRef;
-int sqlblob_fromstr(char *instr, int *l, blob **val);
-int sqlblob_tostr(str *tostr, int *l, const blob *p);
 str sqlcatalogRef;
 str startProfiler(void);
 str startRef;
diff --git a/clients/mapiclient/dotmonetdb.c b/clients/mapiclient/dotmonetdb.c
--- a/clients/mapiclient/dotmonetdb.c
+++ b/clients/mapiclient/dotmonetdb.c
@@ -97,8 +97,7 @@ parse_dotmonetdb(char **user, char **pas
                        } else if (strcmp(buf, "language") == 0) {
                                /* make sure we don't set garbage */
                                if (strcmp(q, "sql") != 0 &&
-                                   strcmp(q, "mal") != 0 &&
-                                   strcmp(q, "jaql") != 0) {
+                                   strcmp(q, "mal") != 0) {
                                        fprintf(stderr, "%s:%d: unsupported "
                                                "language: %s\n",
                                                cfile, line, q);
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1158,7 +1158,10 @@ TESTrenderer(MapiHdl hdl)
                                   strcmp(tp, "dbl") == 0) {
                                char buf[32];
                                int j;
-                               double v = strtod(s, NULL);
+                               double v;
+                               if (strcmp(s, "-0") == 0) /* normalize -0 */
+                                       s = "0";
+                               v = strtod(s, NULL);
                                for (j = 4; j < 11; j++) {
                                        snprintf(buf, sizeof(buf), "%.*g", j, 
v);
                                        if (v == strtod(buf, NULL))
@@ -1168,10 +1171,13 @@ TESTrenderer(MapiHdl hdl)
                        } else if (strcmp(tp, "real") == 0) {
                                char buf[32];
                                int j;
+                               float v;
+                               if (strcmp(s, "-0") == 0) /* normalize -0 */
+                                       s = "0";
 #ifdef HAVE_STRTOF
-                               float v = strtof(s, NULL);
+                               v = strtof(s, NULL);
 #else
-                               float v = (float) strtod(s, NULL);
+                               v = (float) strtod(s, NULL);
 #endif
                                for (j = 4; j < 6; j++) {
                                        snprintf(buf, sizeof(buf), "%.*g", j, 
v);
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -2971,7 +2971,11 @@ file_rastream(FILE *fp, const char *name
                        s->isutf8 = 1;
                        return s;
                }
-               file_fsetpos(s, pos);
+               if (file_fsetpos(s, pos) < 0) {
+                       /* unlikely: we couldn't seek the file back */
+                       destroy(s);
+                       return NULL;
+               }
        }
 #ifdef _MSC_VER
        if (_fileno(fp) == 0 && _isatty(0)) {
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -289,7 +289,14 @@ BATattach(int tt, const char *heapfile, 
                while ((c = getc(f)) != EOF) {
                        if (n == m) {
                                m += 4096;
-                               p = GDKrealloc(p, m);
+                               s = GDKrealloc(p, m);
+                               if (s == NULL) {
+                                       GDKfree(p);
+                                       BBPreclaim(bn);
+                                       fclose(f);
+                                       return NULL;
+                               }
+                               p = s;
                                s = p + n;
                        }
                        if (c == '\n' && n > 0 && s[-1] == '\r') {
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -216,13 +216,13 @@ HEAPextend(Heap *h, size_t size, int may
                /* try GDKrealloc if the heap size stays within
                 * reasonable limits */
                if (!must_mmap) {
-                       void *p = h->base;
                        h->newstorage = h->storage = STORE_MEM;
                        h->base = GDKrealloc(h->base, size);
-                       HEAPDEBUG fprintf(stderr, "#HEAPextend: extending 
malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->size, 
PTRFMTCAST p, PTRFMTCAST h->base);
+                       HEAPDEBUG fprintf(stderr, "#HEAPextend: extending 
malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->size, 
PTRFMTCAST bak.base, PTRFMTCAST h->base);
                        h->size = size;
                        if (h->base)
                                return GDK_SUCCEED; /* success */
+                       /* bak.base is still valid and may get restored */
                        failure = "h->storage == STORE_MEM && !must_map && 
!h->base";
                }
                /* too big: convert it to a disk-based temporary heap */
@@ -631,7 +631,7 @@ HEAPload_intern(Heap *h, const char *nme
 {
        size_t minsize;
        int ret = 0;
-       char *srcpath, *dstpath;
+       char *srcpath, *dstpath, *tmp;
        int t0;
 
        h->storage = h->newstorage = h->size < 4 * GDK_mmap_pagesize ? 
STORE_MEM : STORE_MMAP;
@@ -678,7 +678,14 @@ HEAPload_intern(Heap *h, const char *nme
         * takes precedence. */
        srcpath = GDKfilepath(h->farmid, BATDIR, nme, ext);
        dstpath = GDKfilepath(h->farmid, BATDIR, nme, ext);
-       srcpath = GDKrealloc(srcpath, strlen(srcpath) + strlen(suffix) + 1);
+       if (srcpath == NULL ||
+           dstpath == NULL ||
+           (tmp = GDKrealloc(srcpath, strlen(srcpath) + strlen(suffix) + 1)) 
== NULL) {
+               GDKfree(srcpath);
+               GDKfree(dstpath);
+               return GDK_FAIL;
+       }
+       srcpath = tmp;
        strcat(srcpath, suffix);
 
        t0 = GDKms();
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -1745,10 +1745,15 @@ dumpPointsPoint(BAT *idBAT, BAT *geomBAT
        int lvlDigitsNum = 10;  //MAX_UNIT = 4,294,967,295
        str err = MAL_SUCCEED;
 
+       if (pointWKB == NULL)
+               throw(MAL, "geom.Dump", MAL_MALLOC_FAIL);
+
        (*lvl)++;
        newPath = GDKmalloc(pathLength + lvlDigitsNum + 1);
-       if( newPath == NULL)
-               throw(MAL, "geom.PointsPoint", MAL_MALLOC_FAIL);
+       if (newPath == NULL) {
+               GDKfree(pointWKB);
+               throw(MAL, "geom.Dump", MAL_MALLOC_FAIL);
+       }
        sprintf(newPath, "%s%u", path, *lvl);
 
        if (BUNappend(idBAT, newPath, TRUE) != GDK_SUCCEED ||
@@ -1776,7 +1781,7 @@ dumpPointsLineString(BAT *idBAT, BAT *ge
        if (err != MAL_SUCCEED)
                return err;
 
-       for (i = 0; i < pointsNum; i++) {
+       for (i = 0; i < pointsNum && err == MAL_SUCCEED; i++) {
                GEOSGeometry *pointGeometry = GEOSGeomGetPointN(geosGeometry, 
i);
 
                if (pointGeometry == NULL)
@@ -1803,13 +1808,13 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
 
        //get the exterior ring of the polygon
        exteriorRingGeometry = GEOSGetExteriorRing(geosGeometry);
-       if (!exteriorRingGeometry)
+       if (exteriorRingGeometry == NULL)
                throw(MAL, "geom.DumpPoints", "GEOSGetExteriorRing failed");
 
        (*lvl)++;
        newPath = GDKmalloc(pathLength + lvlDigitsNum + extraLength + 1);
-       if( newPath == NULL)
-               throw(MAL,"geom.dumpPointsPolygon",MAL_MALLOC_FAIL);
+       if (newPath == NULL)
+               throw(MAL, "geom.DumpPoints", MAL_MALLOC_FAIL);
        sprintf(newPath, "%s%u%s", path, *lvl, extraStr);
 
        //get the points in the exterior ring
@@ -1821,7 +1826,7 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
        //check the interior rings
        numInteriorRings = GEOSGetNumInteriorRings(geosGeometry);
        if (numInteriorRings == -1)
-               throw(MAL, "geom.NumPoints", "GEOSGetNumInteriorRings failed");
+               throw(MAL, "geom.DumpPoints", "GEOSGetNumInteriorRings failed");
 
        // iterate over the interiorRing and transform each one of them
        for (i = 0; i < numInteriorRings; i++) {
@@ -1829,6 +1834,8 @@ dumpPointsPolygon(BAT *idBAT, BAT *geomB
                lvlDigitsNum = 10;      //MAX_UNIT = 4,294,967,295
 
                newPath = GDKmalloc(pathLength + lvlDigitsNum + extraLength + 
1);
+               if (newPath == NULL)
+                       throw(MAL, "geom.DumpPoints", MAL_MALLOC_FAIL);
                sprintf(newPath, "%s%u%s", path, *lvl, extraStr);
 
                err = dumpPointsLineString(idBAT, geomBAT, 
GEOSGetInteriorRingN(geosGeometry, i), newPath);
@@ -1862,8 +1869,8 @@ dumpPointsMultiGeometry(BAT *idBAT, BAT 
                lvl++;
 
                newPath = GDKmalloc(pathLength + lvlDigitsNum + extraLength + 
1);
-               if( newPath == NULL)
-                       throw(MAL,"geom.dumpPointsGeometry",MAL_MALLOC_FAIL);
+               if (newPath == NULL)
+                       throw(MAL, "geom.DumpPoints", MAL_MALLOC_FAIL);
                sprintf(newPath, "%s%u%s", path, lvl, extraStr);
 
                //*secondLevel = 0;
@@ -2171,8 +2178,8 @@ wkbFROMSTR_withSRID(char *geomWKT, int *
                size_t sizeOfInfo = strlen(geomWKT) - strlen(polyhedralSurface);
                geomWKT_original = geomWKT;
                geomWKT = GDKmalloc(sizeOfInfo + strlen(multiPolygon) + 1);
-               if( geomWKT == NULL)
-                       throw(MAL,"geomWKT",MAL_MALLOC_FAIL);
+               if (geomWKT == NULL)
+                       throw(MAL, "wkb.FromText", MAL_MALLOC_FAIL);
                strcpy(geomWKT, multiPolygon);
                memcpy(geomWKT + strlen(multiPolygon), 
&geomWKT_original[strlen(polyhedralSurface)], sizeOfInfo);
                geomWKT[sizeOfInfo + strlen(multiPolygon)] = '\0';
@@ -2180,13 +2187,23 @@ wkbFROMSTR_withSRID(char *geomWKT, int *
        ////////////////////////// UP TO HERE ///////////////////////////
 
        WKT_reader = GEOSWKTReader_create();
+       if (WKT_reader == NULL) {
+               if (geomWKT_original)
+                       GDKfree(geomWKT);
+               throw(MAL, "wkb.FromText", "GEOSWKTReader_create failed");
+       }
        geosGeometry = GEOSWKTReader_read(WKT_reader, geomWKT);
        GEOSWKTReader_destroy(WKT_reader);
 
-       if (geosGeometry == NULL)
+       if (geosGeometry == NULL) {
+               if (geomWKT_original)
+                       GDKfree(geomWKT);
                throw(MAL, "wkb.FromText", "GEOSWKTReader_read failed");
+       }
 
        if (GEOSGeomTypeId(geosGeometry) == -1) {
+               if (geomWKT_original)
+                       GDKfree(geomWKT);
                GEOSGeom_destroy(geosGeometry);
                throw(MAL, "wkb.FromText", "GEOSGeomTypeId failed");
        }
@@ -2199,8 +2216,11 @@ wkbFROMSTR_withSRID(char *geomWKT, int *
         * want to get the wkb out of it */
        *geomWKB = geos2wkb(geosGeometry);
        GEOSGeom_destroy(geosGeometry);
-       if (*geomWKB == NULL)
+       if (*geomWKB == NULL) {
+               if (geomWKT_original)
+                       GDKfree(geomWKT);
                throw(MAL, "wkb.FromText", "geos2wkb failed");
+       }
 
        *len = (int) wkb_size((*geomWKB)->len);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to