commit 805283d1305f4099b7c59607ba85afc98c7c9588 from: Omar Polo date: Sat Mar 06 17:42:31 2021 UTC [gemtext] fix append and set_buf it wouldn't resume parsing well without these commit - b2cd5e069649931daeb8619734b6e8c8dc697819 commit + 805283d1305f4099b7c59607ba85afc98c7c9588 blob - 58449fbf3f84e94d22c7a8d99f39a5fd3185a91d blob + d9122de6004c046a2708f6e775be460fdbe46cd4 --- gemtext.c +++ gemtext.c @@ -336,6 +336,8 @@ append(struct parser *p, const char *buf, size_t len) newlen = len + p->len; if ((t = calloc(1, newlen)) == NULL) return 0; + memcpy(t, p->buf, p->len); + memcpy(t + p->len, buf, len); free(p->buf); p->buf = t; p->len = newlen; @@ -348,8 +350,10 @@ set_buf(struct parser *p, const char *buf, size_t len) free(p->buf); p->buf = NULL; - if (len == 0) + if (len == 0) { + p->len = 0; return 1; + } if ((p->buf = calloc(1, len)) == NULL) return 0;