diff options
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/geo_ops.c | 22 | ||||
-rw-r--r-- | src/backend/utils/cache/catcache.c | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 6b6510e8e2a..6cb6be5c5fd 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -1390,7 +1390,7 @@ path_in(PG_FUNCTION_ARGS) } base_size = sizeof(path->p[0]) * npts; - size = offsetof(PATH, p[0]) +base_size; + size = offsetof(PATH, p) +base_size; /* Check for integer overflow */ if (base_size / npts != sizeof(path->p[0]) || size <= base_size) @@ -1443,12 +1443,12 @@ path_recv(PG_FUNCTION_ARGS) closed = pq_getmsgbyte(buf); npts = pq_getmsgint(buf, sizeof(int32)); - if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p[0])) / sizeof(Point))) + if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(PATH, p)) / sizeof(Point))) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid number of points in external \"path\" value"))); - size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts; + size = offsetof(PATH, p) +sizeof(path->p[0]) * npts; path = (PATH *) palloc(size); SET_VARSIZE(path, size); @@ -3476,7 +3476,7 @@ poly_in(PG_FUNCTION_ARGS) errmsg("invalid input syntax for type polygon: \"%s\"", str))); base_size = sizeof(poly->p[0]) * npts; - size = offsetof(POLYGON, p[0]) +base_size; + size = offsetof(POLYGON, p) +base_size; /* Check for integer overflow */ if (base_size / npts != sizeof(poly->p[0]) || size <= base_size) @@ -3530,12 +3530,12 @@ poly_recv(PG_FUNCTION_ARGS) int size; npts = pq_getmsgint(buf, sizeof(int32)); - if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p[0])) / sizeof(Point))) + if (npts <= 0 || npts >= (int32) ((INT_MAX - offsetof(POLYGON, p)) / sizeof(Point))) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("invalid number of points in external \"polygon\" value"))); - size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * npts; + size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * npts; poly = (POLYGON *) palloc0(size); /* zero any holes */ SET_VARSIZE(poly, size); @@ -4251,7 +4251,7 @@ path_add(PG_FUNCTION_ARGS) PG_RETURN_NULL(); base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts); - size = offsetof(PATH, p[0]) +base_size; + size = offsetof(PATH, p) +base_size; /* Check for integer overflow */ if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) || @@ -4393,7 +4393,7 @@ path_poly(PG_FUNCTION_ARGS) * Never overflows: the old size fit in MaxAllocSize, and the new size is * just a small constant larger. */ - size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * path->npts; + size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * path->npts; poly = (POLYGON *) palloc(size); SET_VARSIZE(poly, size); @@ -4468,7 +4468,7 @@ box_poly(PG_FUNCTION_ARGS) int size; /* map four corners of the box to a polygon */ - size = offsetof(POLYGON, p[0]) +sizeof(poly->p[0]) * 4; + size = offsetof(POLYGON, p) +sizeof(poly->p[0]) * 4; poly = (POLYGON *) palloc(size); SET_VARSIZE(poly, size); @@ -4502,7 +4502,7 @@ poly_path(PG_FUNCTION_ARGS) * Never overflows: the old size fit in MaxAllocSize, and the new size is * smaller by a small constant. */ - size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * poly->npts; + size = offsetof(PATH, p) +sizeof(path->p[0]) * poly->npts; path = (PATH *) palloc(size); SET_VARSIZE(path, size); @@ -5181,7 +5181,7 @@ circle_poly(PG_FUNCTION_ARGS) errmsg("must request at least 2 points"))); base_size = sizeof(poly->p[0]) * npts; - size = offsetof(POLYGON, p[0]) +base_size; + size = offsetof(POLYGON, p) +base_size; /* Check for integer overflow */ if (base_size / npts != sizeof(poly->p[0]) || size <= base_size) diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 2e4d0b393a3..1af43c6de67 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -1590,7 +1590,7 @@ SearchCatCacheList(CatCache *cache, oldcxt = MemoryContextSwitchTo(CacheMemoryContext); nmembers = list_length(ctlist); cl = (CatCList *) - palloc(sizeof(CatCList) + nmembers * sizeof(CatCTup *)); + palloc(offsetof(CatCList, members) +nmembers * sizeof(CatCTup *)); heap_copytuple_with_tuple(ntp, &cl->tuple); MemoryContextSwitchTo(oldcxt); heap_freetuple(ntp); |