1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-08 11:42:09 +03:00

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
This commit is contained in:
Noah Misch
2019-06-30 17:34:17 -07:00
parent da53be23d1
commit 459c3cdb4a
4 changed files with 17 additions and 10 deletions

View File

@ -71,8 +71,8 @@ array_iter_setup(array_iter *it, AnyArrayType *a)
{
it->datumptr = NULL;
it->isnullptr = NULL;
it->dataptr = ARR_DATA_PTR(&a->flt);
it->bitmapptr = ARR_NULLBITMAP(&a->flt);
it->dataptr = ARR_DATA_PTR((ArrayType *) a);
it->bitmapptr = ARR_NULLBITMAP((ArrayType *) a);
}
it->bitmask = 1;
}