Skip to contentSkip to conversation

memory leak in normal/command.c(grub_command_find)?

DISCUSSION Mike Small 2 participants 2 messages Nov 14, 2005 – Nov 18, 2005

lore
Share & tools
lore

Mike Small

author
#0 lore raw

Hello,

It looks to me like there is a memory leak in grub_command_find:

grub_command_t
grub_command_find (char *cmdline)
{
...

again:

for (cmd = grub_command_list; cmd; cmd = cmd->next)

    if (grub_strcmp (cmdline, cmd->name) == 0)
      break;

if (! cmd)

    grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", cmdline);
  else if (cmd->flags & GRUB_COMMAND_FLAG_NOT_LOADED)
    {
      /* Automatically load the command.  */
      if (count == 0)
	{
	  grub_dl_t mod;
	  char *module_name;

	  module_name = grub_strdup (cmd->module_name);
	  if (module_name)
	    {
	      mod = grub_dl_load (module_name);
	      if (mod)
		{
		  grub_dl_ref (mod);
		  count++;
  		  goto again;
		}

	      grub_free (module_name);  <<<< never reached because of goto
	    }
	}

...

Signature · 2 lines
Mike Small
[email protected]
#1 lore raw
Quoted 1 line · Mike Small

It looks to me like there is a memory leak in grub_command_find:

You are right. Thank you.

Okuji