]> git.proxmox.com Git - mirror_corosync.git/commitdiff
don't store (and later deref) NULL upon strdup failure
authorJim Meyering <jim@meyering.net>
Fri, 20 Mar 2009 15:48:27 +0000 (15:48 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 20 Mar 2009 15:48:27 +0000 (15:48 +0000)
* 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

lcr/lcr_ifact.c

index b1ea5dc7d6485b01653a2200c88123544e1d5aba..caaa280b7a4eaad53f9e9ee849b0ec9fd44405b8 100644 (file)
@@ -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