From 362fa1151017494b629d4db81487671557bef0a3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 8 Mar 2012 17:46:45 +0000 Subject: Make serd_node_from_string tolerate NULL. git-svn-id: http://svn.drobilla.net/serd/trunk@332 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/node.c | 4 ++++ tests/serd_test.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/node.c b/src/node.c index 4191dfe4..1644b6fc 100644 --- a/src/node.c +++ b/src/node.c @@ -26,6 +26,10 @@ SERD_API SerdNode serd_node_from_string(SerdType type, const uint8_t* buf) { + if (!buf) { + return SERD_NODE_NULL; + } + uint32_t flags = 0; size_t buf_n_bytes = 0; const size_t buf_n_chars = serd_strlen(buf, &buf_n_bytes, &flags); diff --git a/tests/serd_test.c b/tests/serd_test.c index 11f32ed8..50e761a5 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -372,6 +372,11 @@ main() node.buf, node.n_bytes, node.n_chars, node.flags, node.type); } + node = serd_node_from_string(SERD_URI, NULL); + if (!serd_node_equals(&node, &SERD_NODE_NULL)) { + return failure("Creating node from NULL string failed\n"); + } + // Test serd_node_new_uri_from_string SerdURI base_uri; -- cgit v1.2.1