diff --git a/src/backend/utils/adt/array_userfuncs.c b/src/backend/utils/adt/array_userfuncs.c index 499d3578b3..274e867fdd 100644 --- a/src/backend/utils/adt/array_userfuncs.c +++ b/src/backend/utils/adt/array_userfuncs.c @@ -375,7 +375,7 @@ array_cat(PG_FUNCTION_ARGS) dataoffset = 0; /* marker for no null bitmap */ nbytes = ndatabytes + ARR_OVERHEAD_NONULLS(ndims); } - result = (ArrayType *) palloc(nbytes); + result = (ArrayType *) palloc0(nbytes); SET_VARSIZE(result, nbytes); result->ndim = ndims; result->dataoffset = dataoffset; diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index a234f35eb8..f5218111db 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -1339,7 +1339,7 @@ array_recv(PG_FUNCTION_ARGS) dataoffset = 0; /* marker for no null bitmap */ nbytes += ARR_OVERHEAD_NONULLS(ndim); } - retval = (ArrayType *) palloc(nbytes); + retval = (ArrayType *) palloc0(nbytes); SET_VARSIZE(retval, nbytes); retval->ndim = ndim; retval->dataoffset = dataoffset; @@ -1977,7 +1977,7 @@ array_get_slice(ArrayType *array, bytes += ARR_OVERHEAD_NONULLS(ndim); } - newarray = (ArrayType *) palloc(bytes); + newarray = (ArrayType *) palloc0(bytes); SET_VARSIZE(newarray, bytes); newarray->ndim = ndim; newarray->dataoffset = dataoffset; @@ -2230,7 +2230,7 @@ array_set(ArrayType *array, /* * OK, create the new array and fill in header/dimensions */ - newarray = (ArrayType *) palloc(newsize); + newarray = (ArrayType *) palloc0(newsize); SET_VARSIZE(newarray, newsize); newarray->ndim = ndim; newarray->dataoffset = newhasnulls ? overheadlen : 0; @@ -2560,7 +2560,7 @@ array_set_slice(ArrayType *array, newsize = overheadlen + olddatasize - olditemsize + newitemsize; - newarray = (ArrayType *) palloc(newsize); + newarray = (ArrayType *) palloc0(newsize); SET_VARSIZE(newarray, newsize); newarray->ndim = ndim; newarray->dataoffset = newhasnulls ? overheadlen : 0; @@ -2819,7 +2819,7 @@ array_map(FunctionCallInfo fcinfo, Oid inpType, Oid retType, dataoffset = 0; /* marker for no null bitmap */ nbytes += ARR_OVERHEAD_NONULLS(ndim); } - result = (ArrayType *) palloc(nbytes); + result = (ArrayType *) palloc0(nbytes); SET_VARSIZE(result, nbytes); result->ndim = ndim; result->dataoffset = dataoffset; @@ -2955,7 +2955,7 @@ construct_md_array(Datum *elems, dataoffset = 0; /* marker for no null bitmap */ nbytes += ARR_OVERHEAD_NONULLS(ndims); } - result = (ArrayType *) palloc(nbytes); + result = (ArrayType *) palloc0(nbytes); SET_VARSIZE(result, nbytes); result->ndim = ndims; result->dataoffset = dataoffset; @@ -2979,7 +2979,7 @@ construct_empty_array(Oid elmtype) { ArrayType *result; - result = (ArrayType *) palloc(sizeof(ArrayType)); + result = (ArrayType *) palloc0(sizeof(ArrayType)); SET_VARSIZE(result, sizeof(ArrayType)); result->ndim = 0; result->dataoffset = 0; diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index b8cf9a8d06..2cf2f64411 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -1478,6 +1478,8 @@ path_recv(PG_FUNCTION_ARGS) SET_VARSIZE(path, size); path->npts = npts; path->closed = (closed ? 1 : 0); + /* prevent instability in unused pad bytes */ + path->dummy = 0; for (i = 0; i < npts; i++) { @@ -4253,6 +4255,8 @@ path_add(PG_FUNCTION_ARGS) SET_VARSIZE(result, size); result->npts = (p1->npts + p2->npts); result->closed = p1->closed; + /* prevent instability in unused pad bytes */ + result->dummy = 0; for (i = 0; i < p1->npts; i++) { @@ -4486,6 +4490,8 @@ poly_path(PG_FUNCTION_ARGS) SET_VARSIZE(path, size); path->npts = poly->npts; path->closed = TRUE; + /* prevent instability in unused pad bytes */ + path->dummy = 0; for (i = 0; i < poly->npts; i++) {