---
src/libvirt-php.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index e6a780a..ce9d0b9 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -291,10 +291,17 @@ static void php_libvirt_connection_dtor(zend_rsrc_list_entry *rsrc
TSRMLS_DC)
php_libvirt_connection *conn = (php_libvirt_connection*)rsrc->ptr;
int rv;
- rv = virConnectClose(conn->conn);
- if (rv!=0)
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"virConnectClose failed with %i on
destructor: %s", rv, LIBVIRT_G (last_error));
- conn->conn=NULL;
+ if (conn != NULL)
+ {
+ if (conn->conn != NULL)
+ {
+ rv = virConnectClose(conn->conn);
+ if (rv!=0)
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"virConnectClose failed with %i on
destructor: %s", rv, LIBVIRT_G (last_error));
+ conn->conn=NULL;
+ }
+ efree (conn);
+ }
}
/* Destructor for domain resource */
@@ -303,10 +310,17 @@ static void php_libvirt_domain_dtor(zend_rsrc_list_entry *rsrc
TSRMLS_DC)
php_libvirt_domain *domain = (php_libvirt_domain*)rsrc->ptr;
int rv;
- rv = virDomainFree (domain->domain);
- if (rv != 0)
- php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainFree failed with %i on
destructor: %s", rv, LIBVIRT_G (last_error));
- domain->domain=NULL;
+ if (domain != NULL)
+ {
+ if (domain->domain != NULL)
+ {
+ rv = virDomainFree (domain->domain);
+ if (rv != 0)
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainFree failed with %i on
destructor: %s", rv, LIBVIRT_G (last_error));
+ domain->domain=NULL;
+ }
+ efree (domain);
+ }
}
/* Destructor for storagepool resource */
--
1.7.3.4
�