[sheepdog] [PATCH 2/2] dog: duplicate value which is passed via command line for simplyfing cleaning

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Wed Aug 20 11:07:54 CEST 2014


With this change, vdi_setattr() duplicates value which is passed via
command line with xstrdup(). With this change, dog can free() the
value unconditionally. It makes the intention of the code clear.

Reported-by: Ruoyu <liangry at ucweb.com>
Cc: Ruoyu <liangry at ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 dog/vdi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index 84715b3..cd85b65 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -1286,7 +1286,8 @@ static int vdi_setattr(int argc, char **argv)
 		goto out;
 	}
 
-	value = argv[optind++];
+	value = argv[optind] ? xstrdup(argv[optind]) : NULL;
+	optind++;
 	if (!value && !vdi_cmd_data.delete) {
 		value = xmalloc(SD_MAX_VDI_ATTR_VALUE_LEN);
 
-- 
1.8.3.2




More information about the sheepdog mailing list