Browse Source

Bugfix: Make curses_input return NULL on a blank line, as most callers expect

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
630f9d06cc
2 changed files with 14 additions and 4 deletions
  1. 2 0
      adl.c
  2. 12 4
      miner.c

+ 2 - 0
adl.c

@@ -915,6 +915,8 @@ static float curses_float(const char *query)
 	char *cvar;
 	char *cvar;
 
 
 	cvar = curses_input(query);
 	cvar = curses_input(query);
+	if (unlikely(!cvar))
+		return -1;
 	ret = atof(cvar);
 	ret = atof(cvar);
 	free(cvar);
 	free(cvar);
 	return ret;
 	return ret;

+ 12 - 4
miner.c

@@ -4877,6 +4877,8 @@ int curses_int(const char *query)
 	char *cvar;
 	char *cvar;
 
 
 	cvar = curses_input(query);
 	cvar = curses_input(query);
+	if (unlikely(!cvar))
+		return -1;
 	ret = atoi(cvar);
 	ret = atoi(cvar);
 	free(cvar);
 	free(cvar);
 	return ret;
 	return ret;
@@ -5493,6 +5495,11 @@ retry:
 		goto updated;
 		goto updated;
         } else if (!strncasecmp(&input, "p", 1)) {
         } else if (!strncasecmp(&input, "p", 1)) {
 			char *prilist = curses_input("Enter new pool priority (comma separated list)");
 			char *prilist = curses_input("Enter new pool priority (comma separated list)");
+			if (!prilist)
+			{
+				wlogprint("Not changing priorities\n");
+				goto retry;
+			}
 			int res = prioritize_pools(prilist, &i);
 			int res = prioritize_pools(prilist, &i);
 			free(prilist);
 			free(prilist);
 			switch (res) {
 			switch (res) {
@@ -5715,7 +5722,7 @@ retry:
 		default_save_file(filename);
 		default_save_file(filename);
 		sprintf(prompt, "Config filename to write (Enter for default) [%s]", filename);
 		sprintf(prompt, "Config filename to write (Enter for default) [%s]", filename);
 		str = curses_input(prompt);
 		str = curses_input(prompt);
-		if (strcmp(str, "-1")) {
+		if (str) {
 			struct stat statbuf;
 			struct stat statbuf;
 
 
 			strcpy(filename, str);
 			strcpy(filename, str);
@@ -5727,8 +5734,6 @@ retry:
 					goto retry;
 					goto retry;
 			}
 			}
 		}
 		}
-		else
-			free(str);
 		fcfg = fopen(filename, "w");
 		fcfg = fopen(filename, "w");
 		if (!fcfg) {
 		if (!fcfg) {
 			wlogprint("Cannot open or create file\n");
 			wlogprint("Cannot open or create file\n");
@@ -7826,7 +7831,10 @@ char *curses_input(const char *query)
 	wlogprint("%s:\n", query);
 	wlogprint("%s:\n", query);
 	wgetnstr(logwin, input, 255);
 	wgetnstr(logwin, input, 255);
 	if (!strlen(input))
 	if (!strlen(input))
-		strcpy(input, "-1");
+	{
+		free(input);
+		input = NULL;
+	}
 	leaveok(logwin, true);
 	leaveok(logwin, true);
 	noecho();
 	noecho();
 	return input;
 	return input;