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 <[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to