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));
 }
 
-- 
1.7.3.4
�

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

Reply via email to