From add5dd1b9a9ba8c58cdc6ca0bb62d287acb56278 Mon Sep 17 00:00:00 2001 From: Vicent Marti Date: Thu, 4 Sep 2014 19:40:27 +0200 Subject: Remove warnings --- src/inlines.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/inlines.c') 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; } -- cgit v1.2.3