From ed94658ad976c19634fd21c599e94923fd5e46c9 Mon Sep 17 00:00:00 2001 From: jdp Date: Fri, 20 Aug 1999 22:33:44 +0000 Subject: Add a NULL pointer check whose absence could cause segmentation violations in certain obscure cases involving failed dlopens. Many thanks to Archie Cobbs for providing me with a good test case. Eliminate a block that existed only to localize a declaration. --- libexec/rtld-elf/rtld.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libexec/rtld-elf') diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 796742a..f1dd696 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: rtld.c,v 1.28 1999/07/14 04:09:11 jdp Exp $ + * $Id: rtld.c,v 1.29 1999/07/18 00:02:19 jdp Exp $ */ /* @@ -1523,14 +1523,14 @@ unload_object(Obj_Entry *root, bool do_fini_funcs) static void unref_object_dag(Obj_Entry *root) { + const Needed_Entry *needed; + assert(root->refcount != 0); root->refcount--; - if (root->refcount == 0) { - const Needed_Entry *needed; - + if (root->refcount == 0) for (needed = root->needed; needed != NULL; needed = needed->next) - unref_object_dag(needed->obj); - } + if (needed->obj != NULL) + unref_object_dag(needed->obj); } /* -- cgit v1.1