c6d234
commit dbba87d531ad3ea372eba6cb56436a231ca7fb32
c6d234
Author: Dmitry V. Levin <ldv@altlinux.org>
c6d234
Date:   Wed Dec 27 22:12:51 2017 +0000
c6d234
c6d234
    elf: check for rpath emptiness before making a copy of it
c6d234
c6d234
    * elf/dl-load.c (decompose_rpath): Check for rpath emptiness before
c6d234
    making a copy of it.
c6d234
c6d234
Index: glibc-2.17-c758a686/elf/dl-load.c
c6d234
===================================================================
c6d234
--- glibc-2.17-c758a686.orig/elf/dl-load.c
c6d234
+++ glibc-2.17-c758a686/elf/dl-load.c
c6d234
@@ -550,7 +550,6 @@ decompose_rpath (struct r_search_path_st
c6d234
 {
c6d234
   /* Make a copy we can work with.  */
c6d234
   const char *where = l->l_name;
c6d234
-  char *copy;
c6d234
   char *cp;
c6d234
   struct r_search_path_elem **result;
c6d234
   size_t nelems;
c6d234
@@ -589,22 +588,21 @@ decompose_rpath (struct r_search_path_st
c6d234
       while (*inhp != '\0');
c6d234
     }
c6d234
 
c6d234
+  /* Ignore empty rpaths.  */
c6d234
+  if (*rpath == '\0')
c6d234
+    {
c6d234
+      sps->dirs = (struct r_search_path_elem **) -1;
c6d234
+      return false;
c6d234
+    }
c6d234
+
c6d234
   /* Make a writable copy.  */
c6d234
-  copy = local_strdup (rpath);
c6d234
+  char *copy = local_strdup (rpath);
c6d234
   if (copy == NULL)
c6d234
     {
c6d234
       errstring = N_("cannot create RUNPATH/RPATH copy");
c6d234
       goto signal_error;
c6d234
     }
c6d234
 
c6d234
-  /* Ignore empty rpaths.  */
c6d234
-  if (*copy == 0)
c6d234
-    {
c6d234
-      free (copy);
c6d234
-      sps->dirs = (struct r_search_path_elem **) -1;
c6d234
-      return false;
c6d234
-    }
c6d234
-
c6d234
   /* Count the number of necessary elements in the result array.  */
c6d234
   nelems = 0;
c6d234
   for (cp = copy; *cp != '\0'; ++cp)