Merge pull request #11 from cyrilbur-ibm/issues_10

Fix invalid queue removal in bt_q_drop
diff --git a/btbridged.c b/btbridged.c
index c42cbeb..fe692bb 100644
--- a/btbridged.c
+++ b/btbridged.c
@@ -210,19 +210,16 @@
 static struct bt_queue *bt_q_drop(struct btbridged_context *context, struct bt_queue *element)
 {
 	struct bt_queue *r;
-	struct bt_queue *bt_q;
 
 	assert(context);
 
-	bt_q = context->bt_q;
-	if (!element || !bt_q)
+	if (!element || !context || !context->bt_q)
 		return NULL;
 
-
-	r = bt_q;
-	if (r == bt_q) {
-		context->bt_q = bt_q->next;
+	if (element == context->bt_q) {
+		context->bt_q = context->bt_q->next;
 	} else {
+		r = context->bt_q;
 		while (r && r->next != element)
 			r = r->next;