diff --git a/css.c b/css.c index 47800d0..fd9ede9 100644 --- a/css.c +++ b/css.c @@ -54,15 +54,13 @@ mkd_css(Document *d, char **res) stylesheets(d->code, &f); if ( (size = S(f)) > 0 ) { + /* null-terminate, then strdup() into a free()able memory + * chunk + */ EXPAND(f) = 0; - /* HACK ALERT! HACK ALERT! HACK ALERT! */ - *res = T(f);/* we know that a T(Cstring) is a character pointer */ - /* so we can simply pick it up and carry it away, */ - /* leaving the husk of the Ctring on the stack */ - /* END HACK ALERT */ + *res = strdup(T(f)); } - else - DELETE(f); + DELETE(f); return size; } return EOF; diff --git a/xml.c b/xml.c index da48ec8..f71b05c 100644 --- a/xml.c +++ b/xml.c @@ -74,9 +74,10 @@ mkd_xml(char *p, int size, char **res) else Csputc(c, &f); } - /* HACK ALERT! HACK ALERT! HACK ALERT! */ - *res = T(f); /* we know that a T(Cstring) is a character pointer */ - /* so we can simply pick it up and carry it away, */ - return S(f); /* leaving the husk of the Ctring on the stack */ - /* END HACK ALERT */ + /* null terminate, strdup() into a free()able memory block, + * and return the size of everything except the null terminator + */ + EXPAND(f) = 0; + *res = strdup(T(f)); + return S(f)-1; }