Skip to content

Commit

Permalink
util/grub-install: rearrange code to avoid memory leak.
Browse files Browse the repository at this point in the history
Found by: Coverity scan.
  • Loading branch information
arvidjaar committed Jan 26, 2015
1 parent e61f4eb commit be0743b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions util/grub-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,17 +615,14 @@ device_map_check_duplicates (const char *dev_map)
char **d;
size_t i;

d = xmalloc (alloced * sizeof (d[0]));

if (dev_map[0] == '\0')
return;

fp = grub_util_fopen (dev_map, "r");
if (! fp)
{
free (d);
return;
}
return;

d = xmalloc (alloced * sizeof (d[0]));

while (fgets (buf, sizeof (buf), fp))
{
Expand Down

0 comments on commit be0743b

Please sign in to comment.