[postgis-tickets] r17585 - Fix the calculation of gserialized_max_header_size

Raul raul at rmr.ninja
Tue Jul 9 08:33:24 PDT 2019


Author: algunenano
Date: 2019-07-09 08:33:24 -0700 (Tue, 09 Jul 2019)
New Revision: 17585

Modified:
   trunk/NEWS
   trunk/liblwgeom/gserialized1.c
   trunk/liblwgeom/gserialized2.c
Log:
Fix the calculation of gserialized_max_header_size

Closes #4451
Closes https://github.com/postgis/postgis/pull/433



Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2019-07-09 15:30:01 UTC (rev 17584)
+++ trunk/NEWS	2019-07-09 15:33:24 UTC (rev 17585)
@@ -7,6 +7,7 @@
 * Major highlights *
   - #4433 32-bit hash fix (requires reindexing hash(geometry) indexes) (Raúl Marín)
   - #4445, Fix a bug in geometry_le (Raúl Marín)
+  - #4451, Fix the calculation of gserialized_max_header_size (Raúl Marín)
 
 
 PostGIS 3.0.0alpha3

Modified: trunk/liblwgeom/gserialized1.c
===================================================================
--- trunk/liblwgeom/gserialized1.c	2019-07-09 15:30:01 UTC (rev 17584)
+++ trunk/liblwgeom/gserialized1.c	2019-07-09 15:33:24 UTC (rev 17585)
@@ -113,8 +113,9 @@
 
 uint32_t gserialized1_max_header_size(void)
 {
-	/* read GSERIALIZED size + max bbox according gbox_serialized_size (2 + Z + M) + 1 int for type */
-	return sizeof(GSERIALIZED) + 8 * sizeof(float) + sizeof(int);
+	static const intptr_t size_of_gserialized_up_to_data = (intptr_t) & ((GSERIALIZED *)NULL)->data;
+	/* GSERIALIZED size + max bbox according gbox_serialized_size (XYZM*2) + extended flags + type */
+	return size_of_gserialized_up_to_data + 8 * sizeof(float) + sizeof(uint32_t);
 }
 
 static uint32_t gserialized1_header_size(const GSERIALIZED *gser)

Modified: trunk/liblwgeom/gserialized2.c
===================================================================
--- trunk/liblwgeom/gserialized2.c	2019-07-09 15:30:01 UTC (rev 17584)
+++ trunk/liblwgeom/gserialized2.c	2019-07-09 15:33:24 UTC (rev 17585)
@@ -161,8 +161,9 @@
 
 uint32_t gserialized2_max_header_size(void)
 {
-	/* read GSERIALIZED size + max bbox according gbox_serialized_size (XYZM*2) + extended flags + 1 int for type */
-	return sizeof(GSERIALIZED) + 8 * sizeof(float) + sizeof(uint64_t) + sizeof(int);
+	static const intptr_t size_of_gserialized_up_to_data = (intptr_t) & ((GSERIALIZED *)NULL)->data;
+	/* GSERIALIZED size + max bbox according gbox_serialized_size (XYZM*2) + extended flags + type */
+	return size_of_gserialized_up_to_data + 8 * sizeof(float) + sizeof(uint64_t) + sizeof(uint32_t);
 }
 
 



More information about the postgis-tickets mailing list