Skip to content

Commit e696f6a

Browse files
committed
Fixes to JSON conversion functions.
1 parent 7e2bd7e commit e696f6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

postgres_protobuf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Datum protobuf_to_json_text(PG_FUNCTION_ARGS) {
240240
bytea* result =
241241
static_cast<bytea*>(palloc0_or_throw_bad_alloc(result_size));
242242
SET_VARSIZE(result, result_size);
243-
memcpy(VARDATA(result), json_str.data(), result_size);
243+
memcpy(VARDATA(result), json_str.data(), json_str.size());
244244
PG_RETURN_TEXT_P(result);
245245
} catch (const std::bad_alloc& e) {
246246
ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory")));
@@ -275,7 +275,7 @@ Datum protobuf_from_json_text(PG_FUNCTION_ARGS) {
275275
bytea* result =
276276
static_cast<bytea*>(palloc0_or_throw_bad_alloc(result_size));
277277
SET_VARSIZE(result, result_size);
278-
memcpy(VARDATA(result), proto_str.data(), result_size);
278+
memcpy(VARDATA(result), proto_str.data(), proto_str.size());
279279
PG_RETURN_BYTEA_P(result);
280280
} catch (const std::bad_alloc& e) {
281281
ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory")));

0 commit comments

Comments
 (0)