mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Fix a second cause of undersized pallocs for btree_gist indexes on macaddr.
gbt_macad_union also allocated 12-byte structs where we really need 16. Per report from Andres Freund. No back-patch since there's no current risk of a real problem.
This commit is contained in:
		@@ -12,6 +12,7 @@ typedef struct
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	macaddr		lower;
 | 
						macaddr		lower;
 | 
				
			||||||
	macaddr		upper;
 | 
						macaddr		upper;
 | 
				
			||||||
 | 
						char		pad[4];			/* make struct size = sizeof(gbtreekey16) */
 | 
				
			||||||
} macKEY;
 | 
					} macKEY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@@ -143,7 +144,7 @@ Datum
 | 
				
			|||||||
gbt_macad_union(PG_FUNCTION_ARGS)
 | 
					gbt_macad_union(PG_FUNCTION_ARGS)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
 | 
						GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
 | 
				
			||||||
	void	   *out = palloc(sizeof(macKEY));
 | 
						void	   *out = palloc0(sizeof(macKEY));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*(int *) PG_GETARG_POINTER(1) = sizeof(macKEY);
 | 
						*(int *) PG_GETARG_POINTER(1) = sizeof(macKEY);
 | 
				
			||||||
	PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
 | 
						PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user