From 26d98ca94f2f049e8767b4a9a33d185a3d7ea0fd Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 24 Oct 2013 12:43:19 -0700 Subject: Merge from Google-internal development: - rewritten decoder; interpreted decoder is bytecode-based, JIT decoder no longer falls back to the interpreter. - C++ improvements: C++11-compatible iterators, upb::reffed_ptr for RAII refcounting, better upcast/downcast support. - removed the gross upb_value abstraction from public upb.h. --- upb/pb/glue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'upb/pb/glue.c') diff --git a/upb/pb/glue.c b/upb/pb/glue.c index 2c621f4..9027e0f 100644 --- a/upb/pb/glue.c +++ b/upb/pb/glue.c @@ -19,7 +19,7 @@ upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n, // Create handlers. const upb_handlers *reader_h = upb_descreader_gethandlers(&reader_h); const upb_handlers *decoder_h = - upb_pbdecoder_gethandlers(reader_h, false, &decoder_h); + upb_pbdecoder_gethandlers(reader_h, true, &decoder_h); // Create pipeline. upb_pipeline pipeline; @@ -68,8 +68,8 @@ char *upb_readfile(const char *filename, size_t *len) { long size = ftell(f); if(size < 0) goto error; if(fseek(f, 0, SEEK_SET) != 0) goto error; - char *buf = malloc(size); - if(fread(buf, size, 1, f) != 1) goto error; + char *buf = malloc(size + 1); + if(size && fread(buf, size, 1, f) != 1) goto error; fclose(f); if (len) *len = size; return buf; -- cgit v1.2.3