Opened 14 years ago

Closed 14 years ago

Last modified 14 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)

in reply to:  description ; comment:1 by glynn, 14 years ago

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).

in reply to:  1 ; comment:2 by hamish, 14 years ago

Replying to glynn:

Fixed in r40399 (trunk).

shall we backport?

in reply to:  2 comment:3 by glynn, 14 years ago

Replying to hamish:

shall we backport?

I see no reason not to.

comment:4 by neteler, 14 years ago

Resolution: fixed
Status: newclosed

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

comment:5 by mloskot, 14 years ago

Thank you guys!

Note: See TracTickets for help on using tickets.