If line contains single word, line and argv[0] are aliases, so
no NULL dereference is possible, but Coverity does not know it.
Change code to avoid ambiguity and also remove redundant call to
grub_strchr.
CID: 86725
/* In case of an assignment set the environment accordingly
instead of calling a function. */
- if (n == 1 && grub_strchr (line, '='))
+ if (n == 1)
{
char *val = grub_strchr (args[0], '=');
- val[0] = 0;
- grub_env_set (args[0], val + 1);
- val[0] = '=';
- goto quit;
+
+ if (val)
+ {
+ val[0] = 0;
+ grub_env_set (args[0], val + 1);
+ val[0] = '=';
+ goto quit;
+ }
}
/* Get the command name. */
}
quit:
+ /* Arguments are returned in single memory chunk separated by zeroes */
grub_free (args[0]);
grub_free (args);