From 04c31f89d4335386f13cbf659a7383c08c6cf3b4 Mon Sep 17 00:00:00 2001 From: Xavier Mendez Date: Sun, 26 Jul 2015 22:49:58 +0200 Subject: [PATCH] Palliate another effect of rewinding --- src/document.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/document.c b/src/document.c index b057d297..3831b3c3 100644 --- a/src/document.c +++ b/src/document.c @@ -1008,7 +1008,11 @@ char_autolink_www(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size HOEDOWN_BUFPUTSL(link_url, "http://"); hoedown_buffer_put(link_url, link->data, link->size); - ob->size -= rewind; + if (ob->size > rewind) + ob->size -= rewind; + else + ob->size = 0; + if (doc->md.normal_text) { link_text = newbuf(doc, BUFFER_SPAN); doc->md.normal_text(link_text, link, &doc->data); @@ -1036,7 +1040,11 @@ char_autolink_email(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, si link = newbuf(doc, BUFFER_SPAN); if ((link_len = hoedown_autolink__email(&rewind, link, data, offset, size, 0)) > 0) { - ob->size -= rewind; + if (ob->size > rewind) + ob->size -= rewind; + else + ob->size = 0; + doc->md.autolink(ob, link, HOEDOWN_AUTOLINK_EMAIL, &doc->data); } @@ -1056,7 +1064,11 @@ char_autolink_url(hoedown_buffer *ob, hoedown_document *doc, uint8_t *data, size link = newbuf(doc, BUFFER_SPAN); if ((link_len = hoedown_autolink__url(&rewind, link, data, offset, size, 0)) > 0) { - ob->size -= rewind; + if (ob->size > rewind) + ob->size -= rewind; + else + ob->size = 0; + doc->md.autolink(ob, link, HOEDOWN_AUTOLINK_NORMAL, &doc->data); }