Re: [libvirt-php] Fixed set_error when argument is NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/02/2011 05:20 AM, Lyre wrote:
> Avoid freeing a NULL pointer
> ---
>  src/libvirt-php.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/libvirt-php.c b/src/libvirt-php.c
> index 6a76f45..66b1de9 100644
> --- a/src/libvirt-php.c
> +++ b/src/libvirt-php.c
> @@ -237,12 +237,16 @@ PHP_MINFO_FUNCTION(libvirt)
>  */
>  void set_error(char *msg TSRMLS_DC)
>  {
> -	if (msg == NULL) {
> +	if (LIBVIRT_G (last_error) != NULL)
> +	{
>  		efree(LIBVIRT_G (last_error));
> +	}
> +
> +	if (msg == NULL) {
> +		LIBVIRT_G (last_error) = NULL;
>  		return;
>  	}
>  	php_error_docref(NULL TSRMLS_CC, E_WARNING,"%s",msg);
> -	if (LIBVIRT_G (last_error)!=NULL) efree(LIBVIRT_G (last_error));
>  	LIBVIRT_G (last_error)=estrndup(msg,strlen(msg));
>  }
>  
Good pick. Thanks! Pushed now.

Michal

-- 
Michal Novotny <minovotn@xxxxxxxxxx>, RHCE
Virtualization Team (xen userspace), Red Hat

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]