debuggers.hg

changeset 20868:b684d9e57b8f

xc_domain_save: allocate pfn_err before use

Due to recent changes related to xc_map_foreign_bulk, xc_domain_save
segfaults because it tries to use pfn_err without allocating it first.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 19 09:40:30 2010 +0000 (2010-01-19)
parents d7e8b6a66a3d
children 89907dab1aef
files tools/libxc/xc_domain_save.c
line diff
     1.1 --- a/tools/libxc/xc_domain_save.c	Mon Jan 18 14:49:00 2010 +0000
     1.2 +++ b/tools/libxc/xc_domain_save.c	Tue Jan 19 09:40:30 2010 +0000
     1.3 @@ -1273,6 +1273,7 @@ int xc_domain_save(int xc_handle, int io
     1.4              if ( batch == 0 )
     1.5                  goto skip; /* vanishingly unlikely... */
     1.6  
     1.7 +            pfn_err = realloc(pfn_err, sizeof(int) * batch);
     1.8              region_base = xc_map_foreign_bulk(
     1.9                  xc_handle, dom, PROT_READ, pfn_type, pfn_err, batch);
    1.10              if ( region_base == NULL )
    1.11 @@ -1832,6 +1833,7 @@ int xc_domain_save(int xc_handle, int io
    1.12  
    1.13      free(pfn_type);
    1.14      free(pfn_batch);
    1.15 +    free(pfn_err);
    1.16      free(to_send);
    1.17      free(to_fix);
    1.18      free(to_skip);