diff options
-rw-r--r-- | src/env.c | 10 | ||||
-rw-r--r-- | tests/env_test.c | 4 |
2 files changed, 13 insertions, 1 deletions
@@ -108,7 +108,7 @@ serd_env_get_parsed_base_uri(const SerdEnv* env) const SerdNode* serd_env_base_uri(const SerdEnv* env) { - return env->base_uri_node; + return env ? env->base_uri_node : NULL; } SerdStatus @@ -204,6 +204,10 @@ serd_env_qualify_in_place(const SerdEnv* env, const SerdNode** prefix, SerdStringView* suffix) { + if (!env) { + return false; + } + for (size_t i = 0; i < env->n_prefixes; ++i) { const SerdNode* const prefix_uri = env->prefixes[i].uri; if (uri->n_bytes >= prefix_uri->n_bytes) { @@ -263,6 +267,10 @@ serd_env_expand_in_place(const SerdEnv* env, SerdStringView* uri_prefix, SerdStringView* uri_suffix) { + if (!env) { + return SERD_ERR_BAD_CURIE; + } + const char* const str = serd_node_string(curie); const char* const colon = (const char*)memchr(str, ':', curie->n_bytes + 1); if (curie->type != SERD_CURIE || !colon) { diff --git a/tests/env_test.c b/tests/env_test.c index cc04366d..cff8e3cf 100644 --- a/tests/env_test.c +++ b/tests/env_test.c @@ -46,6 +46,10 @@ test_env(void) SerdEnv* env = serd_env_new(NULL); serd_env_set_prefix(env, pre, eg); + assert(!serd_env_base_uri(NULL)); + assert(!serd_env_expand(NULL, NULL)); + assert(!serd_env_qualify(NULL, NULL)); + assert(!serd_env_base_uri(env)); assert(serd_env_set_base_uri(env, NULL)); assert(serd_env_set_base_uri(env, empty)); |