diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2011-09-20 20:32:25 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2011-09-20 20:32:25 -0700 |
commit | c0a08a6827a294f74b0ee5feaf5542081cff4381 (patch) | |
tree | a54e053d050f648d52369fcf2932fdc7a872703f /upb/pb/textprinter.c | |
parent | 56f7a345d7572e118d4a370bb8e79b328d16bc0e (diff) |
Fixes to get upb to compile inside Google.
Diffstat (limited to 'upb/pb/textprinter.c')
-rw-r--r-- | upb/pb/textprinter.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; } |