Don't read fields of a misaligned ExpandedObjectHeader or AnyArrayType.

Noah Misch <noah@leadboat.com>

Commit: 459c3cdb4ad8323bfe6bcae0186a3831e0c89c94
Author: Noah Misch <noah@leadboat.com>
Date: 2019-07-01T00:34:17Z
Releases: 12.0
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

Files

Discussion