Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#866 closed defect (fixed)

Semantic of free() and G_free() for G_free_key_value()

Reported by: mloskot Owned by: grass-dev@…
Priority: normal Milestone:
Component: LibGIS Version: svn-trunk
Keywords: gdal Cc:
CPU: Unspecified Platform: All

Description

Recently, a bug has been submitted to QGIS and forwarded to GDAL.

IMHO, the problem is in GRASS.

The function is 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)
   {
   }
}

Change History (5)

comment:1 in reply to:  description ; Changed 11 years ago by glynn

Replying to mloskot:

The function is 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.

Fixed in r40399 (trunk).

comment:2 in reply to:  1 ; Changed 11 years ago by hamish

Replying to glynn:

Fixed in r40399 (trunk).

shall we backport?

comment:3 in reply to:  2 Changed 11 years ago by glynn

Replying to hamish:

shall we backport?

I see no reason not to.

comment:4 Changed 11 years ago by neteler

Resolution: fixed
Status: newclosed

Done in r40403 (6.4) and r40404 (6.5).

comment:5 Changed 11 years ago by mloskot

Thank you guys!

Note: See TracTickets for help on using tickets.