diff options
author | Michael Brown | 2011-03-07 03:43:56 +0100 |
---|---|---|
committer | Michael Brown | 2011-03-07 03:43:56 +0100 |
commit | 659c55c1a9dbcc415cf315a091e8358d5967999f (patch) | |
tree | 99e63b46bac23f72ed59152494a61770148d9686 /src/core/image.c | |
parent | [comboot] Do not assume that image has a non-NULL command line (diff) | |
download | ipxe-659c55c1a9dbcc415cf315a091e8358d5967999f.tar.gz ipxe-659c55c1a9dbcc415cf315a091e8358d5967999f.tar.xz ipxe-659c55c1a9dbcc415cf315a091e8358d5967999f.zip |
[image] Allow image_set_cmdline() to clear the command line
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/image.c')
-rw-r--r-- | src/core/image.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/image.c b/src/core/image.c index cb961531..6caa0243 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -95,14 +95,18 @@ void image_set_uri ( struct image *image, struct uri *uri ) { * Set image command line * * @v image Image - * @v cmdline New image command line + * @v cmdline New image command line, or NULL * @ret rc Return status code */ int image_set_cmdline ( struct image *image, const char *cmdline ) { + free ( image->cmdline ); - image->cmdline = strdup ( cmdline ); - if ( ! image->cmdline ) - return -ENOMEM; + image->cmdline = NULL; + if ( cmdline ) { + image->cmdline = strdup ( cmdline ); + if ( ! image->cmdline ) + return -ENOMEM; + } return 0; } |