diff --git a/tools/libs/guest/xg_offline_page.c b/tools/libs/guest/xg_offline_page.c index c42b973363..43bbb5c051 100644 --- a/tools/libs/guest/xg_offline_page.c +++ b/tools/libs/guest/xg_offline_page.c @@ -181,18 +181,14 @@ static int backup_ptes(xen_pfn_t table_mfn, int offset, if (backup->max == backup->cur) { - void *orig = backup->entries; + void *entries = realloc(backup->entries, backup->max * 2 * + sizeof(struct pte_backup_entry)); - backup->entries = realloc( - orig, backup->max * 2 * sizeof(struct pte_backup_entry)); - - if (backup->entries == NULL) - { - free(orig); + if (entries == NULL) return -1; - } - else - backup->max *= 2; + + backup->entries = entries; + backup->max *= 2; } backup->entries[backup->cur].table_mfn = table_mfn;