diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-09-05 10:25:14 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2007-09-05 10:25:14 +0000 |
commit | cddb49171ccc1e479c3a625d8eee67d698a4892e (patch) | |
tree | cabff0e400a647f902d65db8118fa7aa5cd8ba7e | |
parent | b276bab44c88f5bb04c935395915f19718021a2e (diff) |
be extra careful with pointers in session_cmp
-rw-r--r-- | usr.sbin/hoststated/relay.c | 6 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/hoststated/relay.c b/usr.sbin/hoststated/relay.c index d7eb3e9f3c9..3aca58e5cbb 100644 --- a/usr.sbin/hoststated/relay.c +++ b/usr.sbin/hoststated/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.39 2007/09/05 08:48:42 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.40 2007/09/05 10:25:13 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -2364,10 +2364,10 @@ RB_GENERATE(proto_tree, protonode, nodes, relay_proto_cmp); int relay_session_cmp(struct session *a, struct session *b) { - struct relay *rlay = (struct relay *)a->relay; + struct relay *rlay = (struct relay *)b->relay; struct protocol *proto = rlay->proto; - if (proto->cmp != NULL) + if (proto != NULL && proto->cmp != NULL) return ((*proto->cmp)(a, b)); return ((int)a->id - b->id); diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index d7eb3e9f3c9..3aca58e5cbb 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.39 2007/09/05 08:48:42 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.40 2007/09/05 10:25:13 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -2364,10 +2364,10 @@ RB_GENERATE(proto_tree, protonode, nodes, relay_proto_cmp); int relay_session_cmp(struct session *a, struct session *b) { - struct relay *rlay = (struct relay *)a->relay; + struct relay *rlay = (struct relay *)b->relay; struct protocol *proto = rlay->proto; - if (proto->cmp != NULL) + if (proto != NULL && proto->cmp != NULL) return ((*proto->cmp)(a, b)); return ((int)a->id - b->id); |