Browse Source

Free ncpus string earlier to fix mem leak in ENODEV case

Samuel Thibault 13 years ago
parent
commit
9e80e11b4c
1 changed files with 6 additions and 6 deletions
  1. 6 6
      tests/main/starpu_init.c

+ 6 - 6
tests/main/starpu_init.c

@@ -49,18 +49,18 @@ static int check_cpu(int env_cpu, int conf_cpu, int expected_cpu, int *cpu)
 	}
 	ret = starpu_init(&user_conf);
 
-	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
-	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
-
-	*cpu = starpu_cpu_worker_get_count();
-	starpu_shutdown();
-
 	if (env_cpu != -1)
 	{
 		unsetenv("STARPU_NCPUS");
 		free(string);
 	}
 
+	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	*cpu = starpu_cpu_worker_get_count();
+	starpu_shutdown();
+
 	if (expected_cpu == -1)
 	{
 		FPRINTF(stderr, "Number of CPUS: %3d\n", *cpu);