From c0a08a6827a294f74b0ee5feaf5542081cff4381 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 20 Sep 2011 20:32:25 -0700 Subject: Fixes to get upb to compile inside Google. --- upb/pb/textprinter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'upb/pb/textprinter.c') diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c index 434a482..4056b8f 100644 --- a/upb/pb/textprinter.c +++ b/upb/pb/textprinter.c @@ -41,7 +41,7 @@ static int upb_textprinter_putescaped(upb_textprinter *p, const upb_strref *strr // TODO; we could read directly from a bytesrc's buffer instead. // TODO; we could write strrefs to the sink when possible. char dstbuf[4096], *dst = dstbuf, *dstend = dstbuf + sizeof(dstbuf); - char buf[strref->len], *src = buf; + char *buf = malloc(strref->len), *src = buf; char *end = src + strref->len; upb_bytesrc_read(strref->bytesrc, strref->stream_offset, strref->len, buf); @@ -81,8 +81,10 @@ static int upb_textprinter_putescaped(upb_textprinter *p, const upb_strref *strr } // Flush remaining data. CHECK(upb_bytesink_write(p->sink, dst, dst - dstbuf)); + free(buf); return 0; err: + free(buf); return -1; } -- cgit v1.2.3