loader/xnu: fix memory leak.

Foound by: Coverity scan.
This commit is contained in:
Andrei Borzenkov 2015-01-27 21:49:45 +03:00
parent 11aae26cc3
commit fbb4aa1c05
1 changed files with 7 additions and 6 deletions

View File

@ -689,10 +689,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
/* Allocate the space. */
err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE);
if (err)
return err;
goto fail;
err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target);
if (err)
return err;
goto fail;
buf = buf0;
exthead = (struct grub_xnu_extheader *) buf;
@ -709,10 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
else
err = grub_macho_readfile32 (macho, filename, buf);
if (err)
{
grub_macho_close (macho);
return err;
}
goto fail;
grub_macho_close (macho);
buf += machosize;
}
@ -747,6 +744,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
/* Announce to kernel */
return grub_xnu_register_memory ("Driver-", &driversnum, buf_target,
neededspace);
fail:
if (macho)
grub_macho_close (macho);
return err;
}
/* Load mkext. */