aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-04-11 18:49:32 +0000
committerDavid Robillard <d@drobilla.net>2014-04-11 18:49:32 +0000
commit85a7ec2b8e11085b74c3a5966753a0b43a264c8a (patch)
tree07af4e12f66bb695e6969602d06b1b69918a72c3 /src/node.c
parent60df320d954e5a82c7c4abc213bc4d396a3ef271 (diff)
downloadserd-85a7ec2b8e11085b74c3a5966753a0b43a264c8a.tar.gz
serd-85a7ec2b8e11085b74c3a5966753a0b43a264c8a.tar.bz2
serd-85a7ec2b8e11085b74c3a5966753a0b43a264c8a.zip
Minor hardening.
git-svn-id: http://svn.drobilla.net/serd/trunk@459 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/node.c b/src/node.c
index 065ff875..a5305474 100644
--- a/src/node.c
+++ b/src/node.c
@@ -102,7 +102,7 @@ serd_node_new_uri_from_node(const SerdNode* uri_node,
const SerdURI* base,
SerdURI* out)
{
- return (uri_node->type == SERD_URI)
+ return (uri_node->type == SERD_URI && uri_node->buf)
? serd_node_new_uri_from_string(uri_node->buf, base, out)
: SERD_NODE_NULL;
}
@@ -114,7 +114,11 @@ serd_node_new_uri_from_string(const uint8_t* str,
SerdURI* out)
{
if (!str || str[0] == '\0') {
- return serd_node_new_uri(base, NULL, out); // Empty URI => Base URI
+ if (base) {
+ return serd_node_new_uri(base, NULL, out); // Empty URI => Base
+ } else {
+ return SERD_NODE_NULL; // Nonsense
+ }
}
SerdURI uri;
serd_uri_parse(str, &uri);
@@ -340,7 +344,7 @@ SERD_API
void
serd_node_free(SerdNode* node)
{
- if (node->buf) {
+ if (node && node->buf) {
free((uint8_t*)node->buf);
node->buf = NULL;
}