Browse Source

set to NULL a freed pointer; check length before copy

Isidoro Ghezzi 7 years ago
parent
commit
d8c2ca144f
1 changed files with 5 additions and 2 deletions
  1. 5 2
      adl.c

+ 5 - 2
adl.c

@@ -385,9 +385,12 @@ void init_adl(int nDevs)
 		}
 
 		applog(LOG_INFO, "GPU %d %s hardware monitoring enabled", gpu, lpInfo[i].strAdapterName);
-		if (gpus[gpu].name)
+		if (gpus[gpu].name) {
 			free((void*)gpus[gpu].name);
-		gpus[gpu].name = trimmed_strdup(lpInfo[i].strAdapterName);
+			gpus[gpu].name = NULL;
+		}
+		if (lpInfo[i].strAdapterName[0])
+			gpus[gpu].name = trimmed_strdup(lpInfo[i].strAdapterName);
 		data->has_adl = true;
 		/* Flag adl as active if any card is successfully activated */
 		adl_active = true;