summaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2014-09-04 19:40:27 +0200
committerVicent Marti <tanoku@gmail.com>2014-09-09 03:39:16 +0200
commitadd5dd1b9a9ba8c58cdc6ca0bb62d287acb56278 (patch)
tree8104276c31185205e2fcad669b4842d70028fc2f /src/inlines.c
parent8308ed0259a9ee02c55070db656b389c7b4be71d (diff)
Remove warnings
Diffstat (limited to 'src/inlines.c')
-rw-r--r--src/inlines.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 6bb89da..5e0f3e5 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -108,13 +108,26 @@ extern void add_reference(reference** refmap, reference* ref)
}
}
+static unsigned char *bufdup(const unsigned char *buf)
+{
+ unsigned char *new = NULL;
+
+ if (!buf) {
+ int len = strlen((char *)buf);
+ new = malloc(len + 1);
+ memcpy(new, buf, len + 1);
+ }
+
+ return new;
+}
+
inline static node_inl* make_link_from_reference(node_inl* label, reference *ref)
{
node_inl* e = (node_inl*) malloc(sizeof(node_inl));
e->tag = INL_LINK;
e->content.linkable.label = label;
- e->content.linkable.url = strdup(ref->url);
- e->content.linkable.title = ref->title ? strdup(ref->title) : NULL;
+ e->content.linkable.url = bufdup(ref->url);
+ e->content.linkable.title = bufdup(ref->title);
e->next = NULL;
return e;
}