ia64/xen-unstable

changeset 18896:f7f8f44b9292

tools: Fix a few error-path memory leaks.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 09 12:53:19 2008 +0000 (2008-12-09)
parents c0c113ab0be5
children 043aba2b67a1
files tools/python/xen/lowlevel/acm/acm.c tools/python/xen/lowlevel/flask/flask.c tools/python/xen/lowlevel/xc/xc.c
line diff
     1.1 --- a/tools/python/xen/lowlevel/acm/acm.c	Tue Dec 09 12:45:45 2008 +0000
     1.2 +++ b/tools/python/xen/lowlevel/acm/acm.c	Tue Dec 09 12:53:19 2008 +0000
     1.3 @@ -68,6 +68,8 @@ static void *__getssid(int domid, uint32
     1.4          goto out2;
     1.5      } else {
     1.6          *buflen = SSID_BUFFER_SIZE;
     1.7 +        free(buf);
     1.8 +        buf = NULL;
     1.9          goto out2;
    1.10      }
    1.11   out2:
     2.1 --- a/tools/python/xen/lowlevel/flask/flask.c	Tue Dec 09 12:45:45 2008 +0000
     2.2 +++ b/tools/python/xen/lowlevel/flask/flask.c	Tue Dec 09 12:53:19 2008 +0000
     2.3 @@ -55,6 +55,7 @@ static PyObject *pyflask_context_to_sid(
     2.4      xc_handle = xc_interface_open();
     2.5      if (xc_handle < 0) {
     2.6          errno = xc_handle;
     2.7 +        free(buf);
     2.8          return PyErr_SetFromErrno(xc_error_obj);
     2.9      }
    2.10      
     3.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Tue Dec 09 12:45:45 2008 +0000
     3.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Dec 09 12:53:19 2008 +0000
     3.3 @@ -678,19 +678,22 @@ static PyObject *pyxc_get_device_group(X
     3.4  
     3.5      if ( rc < 0 )
     3.6      {
     3.7 -      free(sdev_array); 
     3.8 -      return pyxc_error_to_exception();
     3.9 +        free(sdev_array); 
    3.10 +        return pyxc_error_to_exception();
    3.11      }
    3.12  
    3.13      if ( !num_sdevs )
    3.14      {
    3.15 -       free(sdev_array);
    3.16 -       return Py_BuildValue("s", "");
    3.17 +        free(sdev_array);
    3.18 +        return Py_BuildValue("s", "");
    3.19      }
    3.20  
    3.21      group_str = calloc(num_sdevs, sizeof(dev_str));
    3.22      if (group_str == NULL)
    3.23 +    {
    3.24 +        free(sdev_array);
    3.25          return PyErr_NoMemory();
    3.26 +    }
    3.27  
    3.28      for ( i = 0; i < num_sdevs; i++ )
    3.29      {