[Patch] Fix bounds check in trim_array() - Mailing list pgsql-hackers

From Martin Kalcher
Subject [Patch] Fix bounds check in trim_array()
Date
Msg-id baaeb413-b8a8-4656-5757-ef347e5ec11f@aboutsource.net
Whole thread Raw
Responses Re: [Patch] Fix bounds check in trim_array()
List pgsql-hackers
Hi,

while working on something else i encountered a bug in the trim_array() 
function. The bounds check fails for empty arrays without any 
dimensions. It reads the size of the non existing first dimension to 
determine the arrays length.

   select trim_array('{}'::int[], 10);
   ------------
    {}

   select trim_array('{}'::int[], 100);
   ERROR:  number of elements to trim must be between 0 and 64

The attached patch fixes that check.

Martin
Attachment

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Cleaning up historical portability baggage
Next
From: vignesh C
Date:
Subject: Re: Handle infinite recursion in logical replication setup