aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/setrefs.c5
-rw-r--r--src/include/access/brin_page.h7
-rw-r--r--src/include/replication/slot.h4
-rw-r--r--src/interfaces/libpq/fe-exec.c3
-rw-r--r--src/interfaces/libpq/libpq-int.h4
-rw-r--r--src/pl/plpgsql/src/pl_funcs.c2
-rw-r--r--src/pl/plpgsql/src/plpgsql.h2
7 files changed, 18 insertions, 9 deletions
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index 57195e5d68f..ec828cdd9fb 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -41,9 +41,8 @@ typedef struct
int num_vars; /* number of plain Var tlist entries */
bool has_ph_vars; /* are there PlaceHolderVar entries? */
bool has_non_vars; /* are there other entries? */
- /* array of num_vars entries: */
- tlist_vinfo vars[1]; /* VARIABLE LENGTH ARRAY */
-} indexed_tlist; /* VARIABLE LENGTH STRUCT */
+ tlist_vinfo vars[FLEXIBLE_ARRAY_MEMBER]; /* has num_vars entries */
+} indexed_tlist;
typedef struct
{
diff --git a/src/include/access/brin_page.h b/src/include/access/brin_page.h
index d8fa190912d..44ce5f6d1a4 100644
--- a/src/include/access/brin_page.h
+++ b/src/include/access/brin_page.h
@@ -56,7 +56,12 @@ typedef struct BrinMetaPageData
/* Definitions for revmap pages */
typedef struct RevmapContents
{
- ItemPointerData rm_tids[1]; /* really REVMAP_PAGE_MAXITEMS */
+ /*
+ * This array will fill all available space on the page. It should be
+ * declared [FLEXIBLE_ARRAY_MEMBER], but for some reason you can't do that
+ * in an otherwise-empty struct.
+ */
+ ItemPointerData rm_tids[1];
} RevmapContents;
#define REVMAP_CONTENT_SIZE \
diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h
index d22963d0309..a4001360c43 100644
--- a/src/include/replication/slot.h
+++ b/src/include/replication/slot.h
@@ -130,6 +130,10 @@ typedef struct ReplicationSlot
*/
typedef struct ReplicationSlotCtlData
{
+ /*
+ * This array should be declared [FLEXIBLE_ARRAY_MEMBER], but for some
+ * reason you can't do that in an otherwise-empty struct.
+ */
ReplicationSlot replication_slots[1];
} ReplicationSlotCtlData;
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 691202894fa..3d46e150678 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -892,7 +892,8 @@ pqSaveMessageField(PGresult *res, char code, const char *value)
pfield = (PGMessageField *)
pqResultAlloc(res,
- sizeof(PGMessageField) + strlen(value),
+ offsetof(PGMessageField, contents) +
+ strlen(value) + 1,
TRUE);
if (!pfield)
return; /* out of memory? */
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 008fd67c5bf..64579d29404 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -145,7 +145,7 @@ typedef struct pgMessageField
{
struct pgMessageField *next; /* list link */
char code; /* field code */
- char contents[1]; /* field value (VARIABLE LENGTH) */
+ char contents[FLEXIBLE_ARRAY_MEMBER]; /* value, nul-terminated */
} PGMessageField;
/* Fields needed for notice handling */
@@ -637,7 +637,7 @@ extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
* The SSL implementatation provides these functions (fe-secure-openssl.c)
*/
extern void pgtls_init_library(bool do_ssl, int do_crypto);
-extern int pgtls_init(PGconn *conn);
+extern int pgtls_init(PGconn *conn);
extern PostgresPollingStatusType pgtls_open_client(PGconn *conn);
extern void pgtls_close(PGconn *conn);
extern ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len);
diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c
index 1dcea731e99..b6023cc0144 100644
--- a/src/pl/plpgsql/src/pl_funcs.c
+++ b/src/pl/plpgsql/src/pl_funcs.c
@@ -97,7 +97,7 @@ plpgsql_ns_additem(int itemtype, int itemno, const char *name)
/* first item added must be a label */
Assert(ns_top != NULL || itemtype == PLPGSQL_NSTYPE_LABEL);
- nse = palloc(sizeof(PLpgSQL_nsitem) + strlen(name));
+ nse = palloc(offsetof(PLpgSQL_nsitem, name) +strlen(name) + 1);
nse->itemtype = itemtype;
nse->itemno = itemno;
nse->prev = ns_top;
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index 00f2f773a29..337b98980af 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -329,7 +329,7 @@ typedef struct PLpgSQL_nsitem
int itemtype;
int itemno;
struct PLpgSQL_nsitem *prev;
- char name[1]; /* actually, as long as needed */
+ char name[FLEXIBLE_ARRAY_MEMBER]; /* nul-terminated string */
} PLpgSQL_nsitem;