From bf23b9f975ec97d20ba6381f2457e7b7d6ec0369 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 2 Feb 2013 20:14:05 +0000 Subject: Require a URI for lilv_state_to_string() and fail gracefully otherwise. Fail gracefully when lilv_state_new_from_string() is called on NULL. Fixes #865. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5030 a436a847-0d15-0410-975c-d299462d15a1 --- src/state.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/state.c') diff --git a/src/state.c b/src/state.c index d693f1a..3176fd1 100644 --- a/src/state.c +++ b/src/state.c @@ -647,6 +647,10 @@ lilv_state_new_from_string(LilvWorld* world, LV2_URID_Map* map, const char* str) { + if (!str) { + return NULL; + } + SerdNode base = SERD_NODE_NULL; SerdEnv* env = serd_env_new(&base); SordModel* model = sord_new(world->world, SORD_SPO|SORD_OPS, false); @@ -989,6 +993,11 @@ lilv_state_to_string(LilvWorld* world, const char* uri, const char* base_uri) { + if (!uri) { + LILV_ERROR("Attempt to serialise state with no URI\n"); + return NULL; + } + SerdChunk chunk = { NULL, 0 }; SerdEnv* env = NULL; SerdNode base = serd_node_from_string(SERD_URI, USTR(base_uri)); -- cgit v1.2.1