From f612475c997dee0e23805bb7982ec3e820546f02 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 22 Jun 2012 14:46:39 +0200 Subject: [PATCH] Bug fix: null ptr dereference in base/semaphore If nobody is blocked in a semaphore, nothing can be dequeued. If the semaphore is used for signalling, there can be somebody in the queue, but not necessarily. --- base/include/base/semaphore.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/include/base/semaphore.h b/base/include/base/semaphore.h index 85b7fbef1a..fe87eccdd4 100644 --- a/base/include/base/semaphore.h +++ b/base/include/base/semaphore.h @@ -128,7 +128,9 @@ namespace Genode { * Remove element from queue and wake up the corresponding * blocking thread */ - _queue.dequeue()->wake_up(); + Semaphore_queue::Element * element = _queue.dequeue(); + if (element) + element->wake_up(); } void down()