From cd9d48969d944c3558a77745db389e8b68b46c4b Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Sun, 30 Jun 2019 17:34:17 -0700 Subject: Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType. UBSan complains about this. Instead, cast to a suitable type requiring only 4-byte alignment. DatumGetAnyArrayP() already assumes one can cast between AnyArrayType and ArrayType, so this doesn't introduce a new assumption. Back-patch to 9.5, where AnyArrayType was introduced. Reviewed by Tom Lane. Discussion: https://postgr.es/m/20190629210334.GA1244217@rfd.leadboat.com --- src/include/utils/expandeddatum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include/utils/expandeddatum.h') diff --git a/src/include/utils/expandeddatum.h b/src/include/utils/expandeddatum.h index 7116b860cc4..2346f2d3246 100644 --- a/src/include/utils/expandeddatum.h +++ b/src/include/utils/expandeddatum.h @@ -126,7 +126,7 @@ struct ExpandedObjectHeader */ #define EOH_HEADER_MAGIC (-1) #define VARATT_IS_EXPANDED_HEADER(PTR) \ - (((ExpandedObjectHeader *) (PTR))->vl_len_ == EOH_HEADER_MAGIC) + (((varattrib_4b *) (PTR))->va_4byte.va_header == EOH_HEADER_MAGIC) /* * Generic support functions for expanded objects. -- cgit v1.2.3