Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf2874fe

Browse files
committed
Some more FLEXIBLE_ARRAY_MEMBER fixes.
1 parent33b2a2c commitf2874fe

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

‎src/backend/optimizer/plan/setrefs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ typedef struct
4141
intnum_vars;/* number of plain Var tlist entries */
4242
boolhas_ph_vars;/* are there PlaceHolderVar entries? */
4343
boolhas_non_vars;/* are there other entries? */
44-
/* array of num_vars entries: */
45-
tlist_vinfovars[1];/* VARIABLE LENGTH ARRAY */
46-
}indexed_tlist;/* VARIABLE LENGTH STRUCT */
44+
tlist_vinfovars[FLEXIBLE_ARRAY_MEMBER];/* has num_vars entries */
45+
}indexed_tlist;
4746

4847
typedefstruct
4948
{

‎src/include/access/brin_page.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ typedef struct BrinMetaPageData
5656
/* Definitions for revmap pages */
5757
typedefstructRevmapContents
5858
{
59-
ItemPointerDatarm_tids[1];/* really REVMAP_PAGE_MAXITEMS */
59+
/*
60+
* This array will fill all available space on the page. It should be
61+
* declared [FLEXIBLE_ARRAY_MEMBER], but for some reason you can't do that
62+
* in an otherwise-empty struct.
63+
*/
64+
ItemPointerDatarm_tids[1];
6065
}RevmapContents;
6166

6267
#defineREVMAP_CONTENT_SIZE \

‎src/include/replication/slot.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ typedef struct ReplicationSlot
130130
*/
131131
typedefstructReplicationSlotCtlData
132132
{
133+
/*
134+
* This array should be declared [FLEXIBLE_ARRAY_MEMBER], but for some
135+
* reason you can't do that in an otherwise-empty struct.
136+
*/
133137
ReplicationSlotreplication_slots[1];
134138
}ReplicationSlotCtlData;
135139

‎src/interfaces/libpq/fe-exec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,8 @@ pqSaveMessageField(PGresult *res, char code, const char *value)
892892

893893
pfield= (PGMessageField*)
894894
pqResultAlloc(res,
895-
sizeof(PGMessageField)+strlen(value),
895+
offsetof(PGMessageField,contents)+
896+
strlen(value)+1,
896897
TRUE);
897898
if (!pfield)
898899
return;/* out of memory? */

‎src/interfaces/libpq/libpq-int.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ typedef struct pgMessageField
145145
{
146146
structpgMessageField*next;/* list link */
147147
charcode;/* field code */
148-
charcontents[1];/*fieldvalue (VARIABLE LENGTH) */
148+
charcontents[FLEXIBLE_ARRAY_MEMBER];/* value, nul-terminated */
149149
}PGMessageField;
150150

151151
/* Fields needed for notice handling */
@@ -637,7 +637,7 @@ extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
637637
* The SSL implementatation provides these functions (fe-secure-openssl.c)
638638
*/
639639
externvoidpgtls_init_library(booldo_ssl,intdo_crypto);
640-
externintpgtls_init(PGconn*conn);
640+
externintpgtls_init(PGconn*conn);
641641
externPostgresPollingStatusTypepgtls_open_client(PGconn*conn);
642642
externvoidpgtls_close(PGconn*conn);
643643
externssize_tpgtls_read(PGconn*conn,void*ptr,size_tlen);

‎src/pl/plpgsql/src/pl_funcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ plpgsql_ns_additem(int itemtype, int itemno, const char *name)
9797
/* first item added must be a label */
9898
Assert(ns_top!=NULL||itemtype==PLPGSQL_NSTYPE_LABEL);
9999

100-
nse=palloc(sizeof(PLpgSQL_nsitem)+strlen(name));
100+
nse=palloc(offsetof(PLpgSQL_nsitem,name)+strlen(name)+1);
101101
nse->itemtype=itemtype;
102102
nse->itemno=itemno;
103103
nse->prev=ns_top;

‎src/pl/plpgsql/src/plpgsql.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ typedef struct PLpgSQL_nsitem
329329
intitemtype;
330330
intitemno;
331331
structPLpgSQL_nsitem*prev;
332-
charname[1];/*actually, as long as needed */
332+
charname[FLEXIBLE_ARRAY_MEMBER];/*nul-terminated string */
333333
}PLpgSQL_nsitem;
334334

335335

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp