case '\n':
case '\r':
case '\t':
+ case '"':
if(pos - start_offset > 0)
printbuf_memappend(pb, str + start_offset, pos - start_offset);
if(c == '\b') printbuf_memappend(pb, "\\b", 2);
else if(c == '\n') printbuf_memappend(pb, "\\n", 2);
else if(c == '\r') printbuf_memappend(pb, "\\r", 2);
else if(c == '\t') printbuf_memappend(pb, "\\t", 2);
+ else if(c == '"') printbuf_memappend(pb, "\\\"", 2);
start_offset = ++pos;
break;
default:
p->size = new_size;
p->buf = t;
}
- memcpy(p->buf + p->bpos, buf, size);
+
+ char* tmp = strdup(p->buf);
+ memset( p->buf, 0, p->size);
+ memcpy( p->buf, tmp, strlen(tmp));
+ memcpy(p->buf + p->bpos, buf, size);
+ free(tmp);
+
+
+// memcpy(p->buf + p->bpos, buf, size);
p->bpos += size;
p->buf[p->bpos]= '\0';
return size;