Fixed protocol buffer error caused by not initializing properly

pull/1/head
Xavier Stevens 2015-02-11 12:40:08 -08:00
parent 5b7a88438e
commit 29a7ac49dc
1 changed files with 8 additions and 4 deletions

View File

@ -329,8 +329,10 @@ static bool geography_point_as_decoderbufs_point(Datum datum,
getPoint2d_p(point->point, 0, &p2d); getPoint2d_p(point->point, 0, &p2d);
if (p != NULL) { if (p != NULL) {
p->x = p2d.x; Decoderbufs__Point dp = DECODERBUFS__POINT__INIT;
p->y = p2d.y; 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); 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; break;
case POINTOID: case POINTOID:
p = DatumGetPointP(datum); 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 = palloc(sizeof(Decoderbufs__Point));
datum_msg->datum_point->x = p->x; memcpy(datum_msg->datum_point, &dp, sizeof(dp));
datum_msg->datum_point->y = p->y;
break; break;
default: default:
// PostGIS uses dynamic OIDs so we need to check the type again here // PostGIS uses dynamic OIDs so we need to check the type again here