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.
This commit is contained in:
John Polstra 1999-08-20 22:33:44 +00:00
parent f996ef6395
commit 41f83b07a8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50096

View File

@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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,15 +1523,15 @@ unload_object(Obj_Entry *root, bool do_fini_funcs)
static void static void
unref_object_dag(Obj_Entry *root) unref_object_dag(Obj_Entry *root)
{ {
assert(root->refcount != 0);
root->refcount--;
if (root->refcount == 0) {
const Needed_Entry *needed; const Needed_Entry *needed;
assert(root->refcount != 0);
root->refcount--;
if (root->refcount == 0)
for (needed = root->needed; needed != NULL; needed = needed->next) for (needed = root->needed; needed != NULL; needed = needed->next)
if (needed->obj != NULL)
unref_object_dag(needed->obj); unref_object_dag(needed->obj);
} }
}
/* /*
* Non-mallocing printf, for use by malloc itself. * Non-mallocing printf, for use by malloc itself.