[PATCH] do not leak on error conditions

Danny Kukawka danny.kukawka at web.de
Sat Feb 21 03:12:06 PST 2009


On Freitag, 13. Februar 2009, Guillem Jover wrote:

> diff --git a/hald/device_info.c b/hald/device_info.c
> index e378a2e..6444b54 100644
> --- a/hald/device_info.c
> +++ b/hald/device_info.c
> @@ -852,6 +852,7 @@ handle_merge (struct rule *rule, HalDevice *d)
>
>  					if (d == NULL) {
>  						HAL_ERROR (("Could not find device with udi '%s'", udi_to_merge));
> +						g_free (key);
>  						return FALSE;
>  					}
>  				}

This part causing trouble:

device_info.c: In function ‘handle_merge’:
device_info.c:855: warning: passing argument 1 of ‘g_free’ discards qualifiers 
from pointer target type

key is: const char *key

And btw.: if you want to free key, you have to free it on every single error 
condition (where a return FALSE is used) and at the end in handle_merge(). 

Danny


More information about the hal mailing list