@@ -5190,13 +5190,12 @@ numeric_avg_deserialize(PG_FUNCTION_ARGS)
5190
5190
init_var (& tmp_var );
5191
5191
5192
5192
/*
5193
- * Fake up a StringInfo pointing to the bytea's value so we can "receive"
5194
- * the serialized aggregate state value .
5193
+ * Copy the bytea into a StringInfo so that we can "receive" it using the
5194
+ * standard recv-function infrastructure .
5195
5195
*/
5196
- buf .data = VARDATA_ANY (sstate );
5197
- buf .len = VARSIZE_ANY_EXHDR (sstate );
5198
- buf .maxlen = 0 ;
5199
- buf .cursor = 0 ;
5196
+ initStringInfo (& buf );
5197
+ appendBinaryStringInfo (& buf ,
5198
+ VARDATA_ANY (sstate ), VARSIZE_ANY_EXHDR (sstate ));
5200
5199
5201
5200
result = makeNumericAggStateCurrentContext (false);
5202
5201
@@ -5223,6 +5222,7 @@ numeric_avg_deserialize(PG_FUNCTION_ARGS)
5223
5222
result -> nInfcount = pq_getmsgint64 (& buf );
5224
5223
5225
5224
pq_getmsgend (& buf );
5225
+ pfree (buf .data );
5226
5226
5227
5227
free_var (& tmp_var );
5228
5228
@@ -5306,13 +5306,12 @@ numeric_deserialize(PG_FUNCTION_ARGS)
5306
5306
init_var (& tmp_var );
5307
5307
5308
5308
/*
5309
- * Fake up a StringInfo pointing to the bytea's value so we can "receive"
5310
- * the serialized aggregate state value .
5309
+ * Copy the bytea into a StringInfo so that we can "receive" it using the
5310
+ * standard recv-function infrastructure .
5311
5311
*/
5312
- buf .data = VARDATA_ANY (sstate );
5313
- buf .len = VARSIZE_ANY_EXHDR (sstate );
5314
- buf .maxlen = 0 ;
5315
- buf .cursor = 0 ;
5312
+ initStringInfo (& buf );
5313
+ appendBinaryStringInfo (& buf ,
5314
+ VARDATA_ANY (sstate ), VARSIZE_ANY_EXHDR (sstate ));
5316
5315
5317
5316
result = makeNumericAggStateCurrentContext (false);
5318
5317
@@ -5343,6 +5342,7 @@ numeric_deserialize(PG_FUNCTION_ARGS)
5343
5342
result -> nInfcount = pq_getmsgint64 (& buf );
5344
5343
5345
5344
pq_getmsgend (& buf );
5345
+ pfree (buf .data );
5346
5346
5347
5347
free_var (& tmp_var );
5348
5348
@@ -5677,13 +5677,12 @@ numeric_poly_deserialize(PG_FUNCTION_ARGS)
5677
5677
init_var (& tmp_var );
5678
5678
5679
5679
/*
5680
- * Fake up a StringInfo pointing to the bytea's value so we can "receive"
5681
- * the serialized aggregate state value .
5680
+ * Copy the bytea into a StringInfo so that we can "receive" it using the
5681
+ * standard recv-function infrastructure .
5682
5682
*/
5683
- buf .data = VARDATA_ANY (sstate );
5684
- buf .len = VARSIZE_ANY_EXHDR (sstate );
5685
- buf .maxlen = 0 ;
5686
- buf .cursor = 0 ;
5683
+ initStringInfo (& buf );
5684
+ appendBinaryStringInfo (& buf ,
5685
+ VARDATA_ANY (sstate ), VARSIZE_ANY_EXHDR (sstate ));
5687
5686
5688
5687
result = makePolyNumAggStateCurrentContext (false);
5689
5688
@@ -5707,6 +5706,7 @@ numeric_poly_deserialize(PG_FUNCTION_ARGS)
5707
5706
#endif
5708
5707
5709
5708
pq_getmsgend (& buf );
5709
+ pfree (buf .data );
5710
5710
5711
5711
free_var (& tmp_var );
5712
5712
@@ -5868,13 +5868,12 @@ int8_avg_deserialize(PG_FUNCTION_ARGS)
5868
5868
init_var (& tmp_var );
5869
5869
5870
5870
/*
5871
- * Fake up a StringInfo pointing to the bytea's value so we can "receive"
5872
- * the serialized aggregate state value .
5871
+ * Copy the bytea into a StringInfo so that we can "receive" it using the
5872
+ * standard recv-function infrastructure .
5873
5873
*/
5874
- buf .data = VARDATA_ANY (sstate );
5875
- buf .len = VARSIZE_ANY_EXHDR (sstate );
5876
- buf .maxlen = 0 ;
5877
- buf .cursor = 0 ;
5874
+ initStringInfo (& buf );
5875
+ appendBinaryStringInfo (& buf ,
5876
+ VARDATA_ANY (sstate ), VARSIZE_ANY_EXHDR (sstate ));
5878
5877
5879
5878
result = makePolyNumAggStateCurrentContext (false);
5880
5879
@@ -5890,6 +5889,7 @@ int8_avg_deserialize(PG_FUNCTION_ARGS)
5890
5889
#endif
5891
5890
5892
5891
pq_getmsgend (& buf );
5892
+ pfree (buf .data );
5893
5893
5894
5894
free_var (& tmp_var );
5895
5895
0 commit comments