about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-29 15:57:15 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-29 15:57:15 +0000
commitd1dddedf7893fe70ed5d429485c8bcd0ab43f285 (patch)
tree99420c13234130854769150b8d81f5fe1d2528e3 /stdlib
parent9403ec5d23e7dc209361b3dbae2fdc184e1684aa (diff)
downloadglibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.gz
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.xz
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.zip
Realloc error handling memory leak fix.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/canonicalize.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 7186ad9458..2098d77df2 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -1,5 +1,5 @@
 /* Return the canonical absolute name of a given file.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -122,6 +122,7 @@ canonicalize (const char *name, char *resolved)
 	  if (dest + (end - start) >= rpath_limit)
 	    {
 	      ptrdiff_t dest_offset = dest - rpath;
+	      char *new_rpath;
 
 	      if (resolved)
 		{
@@ -136,10 +137,11 @@ canonicalize (const char *name, char *resolved)
 		new_size += end - start + 1;
 	      else
 		new_size += path_max;
-	      rpath = realloc (rpath, new_size);
+	      new_rpath = (char *) realloc (rpath, new_size);
+	      if (new_rpath == NULL)
+		goto error;
+	      rpath = new_rpath;
 	      rpath_limit = rpath + new_size;
-	      if (rpath == NULL)
-		return NULL;
 
 	      dest = rpath + dest_offset;
 	    }