From 29a7ac49dc455f94ec0bcb52ca47c5a897d152a5 Mon Sep 17 00:00:00 2001 From: Xavier Stevens Date: Wed, 11 Feb 2015 12:40:08 -0800 Subject: [PATCH] Fixed protocol buffer error caused by not initializing properly --- src/decoderbufs.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/decoderbufs.c b/src/decoderbufs.c index 39298af..77e48bd 100644 --- a/src/decoderbufs.c +++ b/src/decoderbufs.c @@ -329,8 +329,10 @@ static bool geography_point_as_decoderbufs_point(Datum datum, getPoint2d_p(point->point, 0, &p2d); if (p != NULL) { - p->x = p2d.x; - p->y = p2d.y; + Decoderbufs__Point dp = DECODERBUFS__POINT__INIT; + dp.x = p2d.x; + dp.y = p2d.y; + memcpy(p, &dp, sizeof(dp)); elog(DEBUG1, "Translating geography to point: (x,y) = (%f,%f)", p->x, p->y); } @@ -406,9 +408,11 @@ static void set_datum_value(Decoderbufs__DatumMessage *datum_msg, Oid typid, break; case POINTOID: p = DatumGetPointP(datum); + Decoderbufs__Point dp = DECODERBUFS__POINT__INIT; + dp.x = p->x; + dp.y = p->y; datum_msg->datum_point = palloc(sizeof(Decoderbufs__Point)); - datum_msg->datum_point->x = p->x; - datum_msg->datum_point->y = p->y; + memcpy(datum_msg->datum_point, &dp, sizeof(dp)); break; default: // PostGIS uses dynamic OIDs so we need to check the type again here