Sfoglia il codice sorgente

don't store (and later deref) NULL upon strdup failure

* lcr_ifact.c (ld_library_path_build, ldso_path_build):
Handle strdup failure.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1882 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jim Meyering 17 anni fa
parent
commit
4e1239b77e
1 ha cambiato i file con 9 aggiunte e 2 eliminazioni
  1. 9 2
      lcr/lcr_ifact.c

+ 9 - 2
lcr/lcr_ifact.c

@@ -200,7 +200,10 @@ static void ld_library_path_build (void)
 
 	p_s = strtok_r (my_ld_library_path, ":", &ptrptr);
 	while (p_s != NULL) {
-		path_list[path_list_entries++] = strdup (p_s);
+		char *p = strdup (p_s);
+		if (p) {
+			path_list[path_list_entries++] = p;
+		}
 		p_s = strtok_r (NULL, ":", &ptrptr);
 	}
 
@@ -243,6 +246,7 @@ static int ldso_path_build (const char *path, const char *filename)
 	}
 
 	while (fgets (string, sizeof (string), fp)) {
+		char *p;
 		if (strlen(string) > 0)
 			string[strlen(string) - 1] = '\0';
 		if (strncmp (string, "include", strlen ("include")) == 0) {
@@ -261,7 +265,10 @@ static int ldso_path_build (const char *path, const char *filename)
 			ldso_path_build (newpath, new_filename);
 			continue;
 		}
-		path_list[path_list_entries++] = strdup (string);
+		p = strdup (string);
+		if (p) {
+			path_list[path_list_entries++] = p;
+		}
 	}
 	fclose(fp);
 #endif