Browse Source

Merge pull request #270 from luke-jr/bugfix_procname

Bugfix: Copy argv[0] given to dirname()
Con Kolivas 13 years ago
parent
commit
28ac422ab8
1 changed files with 4 additions and 1 deletions
  1. 4 1
      cgminer.c

+ 4 - 1
cgminer.c

@@ -5107,6 +5107,7 @@ int main(int argc, char *argv[])
 	bool pools_active = false;
 	bool pools_active = false;
 	struct sigaction handler;
 	struct sigaction handler;
 	struct thr_info *thr;
 	struct thr_info *thr;
+	char *s;
 	unsigned int k;
 	unsigned int k;
 	int i, j;
 	int i, j;
 
 
@@ -5157,7 +5158,9 @@ int main(int argc, char *argv[])
 	opt_kernel_path = alloca(PATH_MAX);
 	opt_kernel_path = alloca(PATH_MAX);
 	strcpy(opt_kernel_path, CGMINER_PREFIX);
 	strcpy(opt_kernel_path, CGMINER_PREFIX);
 	cgminer_path = alloca(PATH_MAX);
 	cgminer_path = alloca(PATH_MAX);
-	strcpy(cgminer_path, dirname(argv[0]));
+	s = strdup(argv[0]);
+	strcpy(cgminer_path, dirname(s));
+	free(s);
 	strcat(cgminer_path, "/");
 	strcat(cgminer_path, "/");
 #ifdef WANT_CPUMINE
 #ifdef WANT_CPUMINE
 	// Hack to make cgminer silent when called recursively on WIN32
 	// Hack to make cgminer silent when called recursively on WIN32