From f328f3786b130f2fa64ebb7f8b403920d2367c81 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 22 Jun 2012 14:54:11 +0200 Subject: [PATCH] Bug fix: null ptr dereference in base/lock Don't fail if nobody is holding the lock. --- base/src/base/lock/lock.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/src/base/lock/lock.cc b/base/src/base/lock/lock.cc index 91b8716ca5..0afc302538 100644 --- a/base/src/base/lock/lock.cc +++ b/base/src/base/lock/lock.cc @@ -110,13 +110,14 @@ void Cancelable_lock::lock() /* check if we are the applicant to be waken up next */ - if (*_owner.applicant_to_wake_up() == myself) { + Applicant *a = _owner.applicant_to_wake_up(); + if (a && (*a == myself)) { + _owner.applicant_to_wake_up(myself.applicant_to_wake_up()); /* otherwise, go through the list of remaining applicants */ } else { - Applicant *a = _owner.applicant_to_wake_up(); for (; a; a = a->applicant_to_wake_up()) { /* remove reference to ourself from the applicants list */