summaryrefslogtreecommitdiff
path: root/lib/qobj.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-12-07 12:16:05 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2016-12-09 17:36:25 +0100
commit3c5070bec0a64918ae87b0992221b8e6c98ff136 (patch)
tree5056722639e4fe8361835715436ed17c454382fe /lib/qobj.c
parentf6eacff4386610eea9fe67ceba7e50f8d87fad4a (diff)
lib: make qobj NULL-safe/aware
reserve qobj ID 0 for a NULL pointer. (No change is needed for lookups since looking up 0 will simply fail and return NULL.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/qobj.c')
-rw-r--r--lib/qobj.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/qobj.c b/lib/qobj.c
index f64972e32a..aeae52e029 100644
--- a/lib/qobj.c
+++ b/lib/qobj.c
@@ -49,7 +49,7 @@ void qobj_reg(struct qobj_node *node, struct qobj_nodetype *type)
node->nid = (uint64_t)random();
node->nid ^= (uint64_t)random() << 32;
}
- while (hash_get (nodes, node, hash_alloc_intern) != node);
+ while (!node->nid || hash_get (nodes, node, hash_alloc_intern) != node);
}
void qobj_unreg(struct qobj_node *node)