fix rpath string memory leak on failed dlopen
authorRich Felker <dalias@aerifal.cx>
Sat, 4 Apr 2015 04:15:19 +0000 (00:15 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 4 Apr 2015 04:15:19 +0000 (00:15 -0400)
when dlopen fails, all partially-loaded libraries need to be unmapped
and freed. any of these libraries using an rpath with $ORIGIN
expansion may have an allocated string for the expanded rpath;
previously, this string was not freed when freeing the library data
structures.

src/ldso/dynlink.c

index 4a3718390a80bff5687424168469d7e387a0067b..f6ed80115c67735bbb0d4c9d186fb90cc7f54ba6 100644 (file)
@@ -1413,6 +1413,8 @@ void *dlopen(const char *file, int mode)
                                free(p->td_index);
                                p->td_index = tmp;
                        }
+                       if (p->rpath != p->rpath_orig)
+                               free(p->rpath);
                        free(p->deps);
                        free(p);
                }