[PATCH] lib: fwts_args: only handle non-zero length short_names

Colin King colin.king at canonical.com
Tue Apr 10 14:17:58 UTC 2012


From: Colin Ian King <colin.king at canonical.com>

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_args.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/src/fwts_args.c b/src/lib/src/fwts_args.c
index 90f3d70..b5ef3e0 100644
--- a/src/lib/src/fwts_args.c
+++ b/src/lib/src/fwts_args.c
@@ -116,14 +116,14 @@ int fwts_args_parse(fwts_framework *fw, int argc, char * const argv[])
 
 		for (i=0; i<options_table->num_options; i++, n++) {
 			char *short_name = options_table->options[i].short_name;
+			size_t len;
 			
 			long_options[n].name    = options_table->options[i].long_name;
 			long_options[n].has_arg = options_table->options[i].has_arg;
 			long_options[n].flag    = 0;
 			long_options[n].val     = 0;
 	
-			if (short_name != NULL) {
-				int len = strlen(short_name);
+			if (short_name && (len = strlen(short_name)) > 0) {
 				if (short_options) {
 					short_options = realloc(short_options,
 						strlen(short_options) + len + 1);
-- 
1.7.9.1





More information about the fwts-devel mailing list