[GRASS-dev] [GRASS GIS] #866: Semantic of free() and G_free() for G_free_key_value()

GRASS GIS trac at osgeo.org
Tue Jan 12 13:06:28 EST 2010


#866: Semantic of free() and G_free() for G_free_key_value()
-------------------------+--------------------------------------------------
 Reporter:  mloskot      |       Owner:  grass-dev at lists.osgeo.org
     Type:  defect       |      Status:  new                      
 Priority:  normal       |   Milestone:                           
Component:  libgis       |     Version:  svn-trunk                
 Keywords:  gdal         |    Platform:  All                      
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------
 Recently, a bug has been submitted [http://trac.osgeo.org/qgis/ticket/2303
 to QGIS] and forwarded [http://trac.osgeo.org/gdal/ticket/3323 to GDAL].

 IMHO, the problem is in GRASS.

 The function is [source:grass/trunk/lib/gis/key_value1.c?@35855#L149
 G_free_key_value] not proof against nullptr and, given purpose of this
 function, if pointer to key is null, it should do nothing. This is a
 standard semantic of free() function in C library. Moreover, G_free
 function already follows semantic of free(), so G_free_key_value() should
 do it as well.

 In other words, it should read as follows:

 {{{
 void G_free_key_value(struct Key_Value *kv)
 {
    if (kv != NULL)
    {
    }
 }
 }}}

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/866>
GRASS GIS <http://grass.osgeo.org>


More information about the grass-dev mailing list