diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | sord/sord.h | 2 | ||||
-rw-r--r-- | src/sord.c | 4 |
3 files changed, 8 insertions, 3 deletions
@@ -4,9 +4,10 @@ sord (0.15.1) unstable; * Return error from sord_inserter_write_statement() if a node can not be written (e.g. undefined prefix) * Make sord_node_get_counted return byte count, and clarify documentation - * Add sord_node_get_string_measured to get both byte and character counts + * Safely return NULL from sord_iter_get() for end iterators + * Add sord_node_get_string_measured() to get both byte and character counts - -- David Robillard <d@drobilla.net> Tue, 15 Mar 2016 14:51:35 -0400 + -- David Robillard <d@drobilla.net> Thu, 17 Mar 2016 21:38:13 -0400 sord (0.14.0) stable; diff --git a/sord/sord.h b/sord/sord.h index e93cff8..eff15af 100644 --- a/sord/sord.h +++ b/sord/sord.h @@ -559,6 +559,8 @@ sord_iter_get(const SordIter* iter, SordQuad quad); /** Return a field of the quad pointed to by `iter`. + + Returns NULL if `iter` is NULL or is at the end. */ SORD_API const SordNode* @@ -445,7 +445,9 @@ sord_iter_get(const SordIter* iter, SordQuad id) const SordNode* sord_iter_get_node(const SordIter* iter, SordQuadIndex index) { - return iter ? ((SordNode**)zix_btree_get(iter->cur))[index] : NULL; + return (!sord_iter_end(iter) + ? ((SordNode**)zix_btree_get(iter->cur))[index] + : NULL); } static bool |