mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:44:18 +00:00 
			
		
		
		
	Handle NULL value properly.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd-set-option.c,v 1.3 2007-10-04 22:04:01 nicm Exp $ */
 | 
			
		||||
/* $Id: cmd-set-option.c,v 1.4 2007-10-04 22:18:48 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -102,17 +102,24 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	number =  strtonum(data->value, 0, UINT_MAX, &errstr);
 | 
			
		||||
 | 
			
		||||
	bool = -1;
 | 
			
		||||
	if (number == 1 ||
 | 
			
		||||
	    strcmp(data->value, "on") == 0 || strcmp(data->value, "yes") == 0)
 | 
			
		||||
	if (data->value != NULL) {
 | 
			
		||||
		number = strtonum(data->value, 0, UINT_MAX, &errstr);
 | 
			
		||||
		
 | 
			
		||||
		bool = -1;
 | 
			
		||||
		if (number == 1 || strcmp(data->value, "on") == 0 ||
 | 
			
		||||
		    strcmp(data->value, "yes") == 0)
 | 
			
		||||
			bool = 1;
 | 
			
		||||
		if (number == 0 || strcmp(data->value, "off") == 0 ||
 | 
			
		||||
		    strcmp(data->value, "no") == 0)
 | 
			
		||||
			bool = 0;
 | 
			
		||||
	} else
 | 
			
		||||
		bool = 1;
 | 
			
		||||
	if (number == 0 ||
 | 
			
		||||
	    strcmp(data->value, "off") == 0 || strcmp(data->value, "no") == 0)
 | 
			
		||||
		bool = 0;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if (strcmp(data->option, "prefix") == 0) {
 | 
			
		||||
		if (data->value == NULL) {
 | 
			
		||||
			ctx->error(ctx, "invalid value");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		key = key_string_lookup_string(data->value);
 | 
			
		||||
		if (key == KEYC_NONE) {
 | 
			
		||||
			ctx->error(ctx, "unknown key: %s", data->value);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user