]> granicus.if.org Git - postgis/commitdiff
Allocate enough space for all possible GBOX string outputs (Raúl Marín Rodríguez)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 17 Oct 2017 16:53:45 +0000 (16:53 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 17 Oct 2017 16:53:45 +0000 (16:53 +0000)
References #3907

git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@15997 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/cunit/cu_geodetic.c
liblwgeom/g_box.c

diff --git a/NEWS b/NEWS
index 2e78e8b4852fd5a9d8781cce9659d13c49379134..4149a3f524d5d368a454f735492d74ac371c4709 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,8 +16,9 @@ PostGIS 2.4.1dev
   - #3891, undefined behaviour in pointarray_to_encoded_polyline
   - #3895, throw error on malformed WKB input
   - #3886, fix rare missing boxes in geometry subdivision
+  - #3907, Allocate enough space for all possible GBOX string outputs (Raúl Marín Rodríguez)
 
 * Enhancements *
+ * Enhancements *
   - #3815, Tiger 2017 data support and option to load zcta5
 
 
index deaacb44f49da568d4ea6b2b54b2728c4e1c81ba..5bcc503b8dd15848e45e494fe93d5ec301723f77 100644 (file)
@@ -1569,6 +1569,28 @@ static void test_lwgeom_area_sphere(void)
        /* end #3393 */
 }
 
+static void test_gbox_to_string_truncated(void)
+{
+       GBOX g = {
+               .flags = 0,
+               .xmin = -DBL_MAX,
+               .xmax = -DBL_MAX,
+               .ymin = -DBL_MAX,
+               .ymax = -DBL_MAX,
+               .zmin = -DBL_MAX,
+               .zmax = -DBL_MAX,
+               .mmin = -DBL_MAX,
+               .mmax = -DBL_MAX,
+       };
+       FLAGS_SET_Z(g.flags, 1);
+       FLAGS_SET_M(g.flags, 1);
+       char *c = gbox_to_string(&g);
+
+       ASSERT_STRING_EQUAL(c, "GBOX((-1.7976931e+308,-1.7976931e+308,-1.7976931e+308,-1.7976931e+308),(-1.7976931e+308,-1.7976931e+308,-1.7976931e+308,-1.7976931e+308))");
+
+       lwfree(c);
+}
+
 /*
 ** Used by test harness to register the tests in this file.
 */
@@ -1598,4 +1620,5 @@ void geodetic_suite_setup(void)
        PG_ADD_TEST(suite, test_lwgeom_segmentize_sphere);
        PG_ADD_TEST(suite, test_ptarray_contains_point_sphere);
        PG_ADD_TEST(suite, test_ptarray_contains_point_sphere_iowa);
+       PG_ADD_TEST(suite, test_gbox_to_string_truncated);
 }
index 0e32ee017a800c4b41f3744cb091f755541b284e..c6f25357f852374889998c941c59e79f53f6aa2a 100644 (file)
@@ -403,7 +403,7 @@ GBOX* gbox_from_string(const char *str)
 
 char* gbox_to_string(const GBOX *gbox)
 {
-       static int sz = 128;
+       static int sz = 138;
        char *str = NULL;
 
        if ( ! gbox )