[postgis-tickets] r17412 - lwout_wkb.c: Address implicit type conversion with value change

Raul raul at rmr.ninja
Wed Apr 24 04:02:21 PDT 2019


Author: algunenano
Date: 2019-04-24 04:02:21 -0700 (Wed, 24 Apr 2019)
New Revision: 17412

Modified:
   trunk/liblwgeom/lwout_wkb.c
Log:
lwout_wkb.c: Address implicit type conversion with value change

lwout_wkb.c:288:16: runtime error: implicit conversion from type 'char' of value -16 (8-bit, signed) to type 'uint8_t' (aka 'unsigned char') changed the value to 240 (8-bit, unsigned)
lwout_wkb.c:654:27: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 2147483663 (32-bit, unsigned) to type 'int' changed the value to -2147483633 (32-bit, signed)
lwout_wkb.c:213:16: runtime error: implicit conversion from type 'char' of value -128 (8-bit, signed) to type 'uint8_t' (aka 'unsigned char') changed the value to 128 (8-bit, unsigned)
lwout_wkb.c:607:27: runtime error: implicit conversion from type 'uint32_t' (aka 'unsigned int') of value 2147483651 (32-bit, unsigned) to type 'int' changed the value to -2147483645 (32-bit, signed)

References #4383



Modified: trunk/liblwgeom/lwout_wkb.c
===================================================================
--- trunk/liblwgeom/lwout_wkb.c	2019-04-24 10:59:37 UTC (rev 17411)
+++ trunk/liblwgeom/lwout_wkb.c	2019-04-24 11:02:21 UTC (rev 17412)
@@ -193,9 +193,10 @@
 /*
 * Integer32
 */
-static uint8_t* integer_to_wkb_buf(const int ival, uint8_t *buf, uint8_t variant)
+static uint8_t *
+integer_to_wkb_buf(const uint32_t ival, uint8_t *buf, uint8_t variant)
 {
-	char *iptr = (char*)(&ival);
+	uint8_t *iptr = (uint8_t *)(&ival);
 	int i = 0;
 
 	if ( sizeof(int) != WKB_INT_SIZE )
@@ -270,7 +271,7 @@
 */
 static uint8_t* double_to_wkb_buf(const double d, uint8_t *buf, uint8_t variant)
 {
-	char *dptr = (char*)(&d);
+	uint8_t *dptr = (uint8_t *)(&d);
 	int i = 0;
 
 	if ( sizeof(double) != WKB_DOUBLE_SIZE )



More information about the postgis-tickets mailing list