about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2010-05-03 13:33:13 -0700
committerPetr Baudis <pasky@ucw.cz>2010-05-12 03:21:21 +0200
commitc4e15a30bd196e2201f4d183fc1bdec4f562be10 (patch)
tree9dd96c4af48f2f3760858c597a0e476515e4e247
parent8ef4dbaf6d8faa91ff42a5d7b8b2c29f1c22bed0 (diff)
downloadglibc-c4e15a30bd196e2201f4d183fc1bdec4f562be10.tar.gz
glibc-c4e15a30bd196e2201f4d183fc1bdec4f562be10.tar.xz
glibc-c4e15a30bd196e2201f4d183fc1bdec4f562be10.zip
Simplify OOM handling in ldconfig.
(cherry picked from commit f2976023940a8ef3bbe0c7e593897e1b612370f1)
-rw-r--r--ChangeLog2
-rw-r--r--elf/chroot_canon.c10
2 files changed, 5 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 48f9aa9339..99638b6ee9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2010-05-03  Ulrich Drepper  <drepper@redhat.com>
 
+	* elf/chroot_canon.c (chroot_canon): Use xmalloc and xrealloc.
+
 	* elf/ldconfig.c (parse_conf_include): Don't fall back to
 	directories named in config file outside the chroot.
 
diff --git a/elf/chroot_canon.c b/elf/chroot_canon.c
index 3c16a43ebb..54a6a4cc96 100644
--- a/elf/chroot_canon.c
+++ b/elf/chroot_canon.c
@@ -1,5 +1,5 @@
 /* Return the canonical absolute name of a given file inside chroot.
-   Copyright (C) 1996,1997,1998,1999,2000,2001,2004,2005
+   Copyright (C) 1996,1997,1998,1999,2000,2001,2004,2005,2010
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -58,9 +58,7 @@ chroot_canon (const char *chroot, const char *name)
       return NULL;
     }
 
-  rpath = malloc (chroot_len + PATH_MAX);
-  if (rpath == NULL)
-    return NULL;
+  rpath = xmalloc (chroot_len + PATH_MAX);
 
   rpath_limit = rpath + chroot_len + PATH_MAX;
 
@@ -109,9 +107,7 @@ chroot_canon (const char *chroot, const char *name)
 		new_size += end - start + 1;
 	      else
 		new_size += PATH_MAX;
-	      new_rpath = (char *) realloc (rpath, new_size);
-	      if (new_rpath == NULL)
-		goto error;
+	      new_rpath = (char *) xrealloc (rpath, new_size);
 	      rpath = new_rpath;
 	      rpath_limit = rpath + new_size;