[postgis-devel] [PostGIS] #1984: geography_btree.c: array subscript is above array bounds [-Warray-bounds]

PostGIS trac at osgeo.org
Mon Oct 1 02:01:04 PDT 2012


#1984: geography_btree.c: array subscript is above array bounds [-Warray-bounds]
---------------------+------------------------------------------------------
 Reporter:  strk     |       Owner:  pramsey      
     Type:  defect   |      Status:  new          
 Priority:  medium   |   Milestone:  PostGIS 2.0.2
Component:  postgis  |     Version:  trunk        
 Keywords:           |  
---------------------+------------------------------------------------------

Comment(by strk):

 Ok the issue here is GIDX->c being defined as a 1-element array, while we
 know it's of variable size instead.

 One way to fix this would be changing its definition from:
 {{{
  typedef struct
  {
         int32 varsize;
         float c[1];
  } GIDX;
 }}}

 To:
 {{{
  typedef struct
  {
         int32 varsize;
         float c[];
  } GIDX;
 }}}

 But doing so would change sizeof(GIDX) to be one float less than possibly
 expected by client code. This may actually simplify some code, but doesn't
 look like we have much testing for that (nothing in the testsuite fails
 with the above changes).

 Another way could be doing the cast from within the GIDX_* macros which
 are using subscripts. Probably safer.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1984#comment:1>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list