Browse Source

Merge commit '081a48f' into bfgminer

Luke Dashjr 12 years ago
parent
commit
eb086d963b
2 changed files with 15 additions and 5 deletions
  1. 2 0
      adl.c
  2. 13 5
      miner.c

+ 2 - 0
adl.c

@@ -922,6 +922,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;

+ 13 - 5
miner.c

@@ -5991,6 +5991,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;
@@ -6703,6 +6705,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) {
@@ -6927,7 +6934,7 @@ retry:
 		default_save_file(filename);
 		default_save_file(filename);
 		snprintf(prompt, sizeof(prompt), "Config filename to write (Enter for default) [%s]", filename);
 		snprintf(prompt, sizeof(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);
@@ -6939,8 +6946,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");
@@ -7115,7 +7120,7 @@ refresh:
 			{
 			{
 				static char *pattern = NULL;
 				static char *pattern = NULL;
 				char *newpattern = curses_input("Enter pattern");
 				char *newpattern = curses_input("Enter pattern");
-				if (strcmp(newpattern, "-1"))
+				if (newpattern)
 				{
 				{
 					free(pattern);
 					free(pattern);
 					pattern = newpattern;
 					pattern = newpattern;
@@ -9865,7 +9870,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;