From 659c55c1a9dbcc415cf315a091e8358d5967999f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Mon, 7 Mar 2011 02:43:56 +0000 Subject: [PATCH] [image] Allow image_set_cmdline() to clear the command line Signed-off-by: Michael Brown --- src/core/image.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/image.c b/src/core/image.c index cb9615311..6caa02434 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; }