diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2016-09-12 11:17:25 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-12 11:17:25 -0700 |
commit | 77c97fd3f29caa5c243294b5f4e6763b3ed3c36f (patch) | |
tree | d1f21edb5732580bb15a26918eb684d139528f89 /upb/descriptor/reader.c | |
parent | b176b976a5f941a73b2247b3ae8473bf1c0c0fa7 (diff) | |
parent | 5a49a3360598abbb2250bd5ebd01ed173a65f8ac (diff) |
Merge pull request #70 from haberman/reffix
Some refcounting fixes.
Diffstat (limited to 'upb/descriptor/reader.c')
-rw-r--r-- | upb/descriptor/reader.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/upb/descriptor/reader.c b/upb/descriptor/reader.c index b515840..e219f18 100644 --- a/upb/descriptor/reader.c +++ b/upb/descriptor/reader.c @@ -573,7 +573,7 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf, static bool field_ononeofindex(void *closure, const void *hd, int32_t index) { upb_descreader *r = closure; upb_oneofdef *o = upb_descreader_getoneof(r, index); - bool ok = upb_oneofdef_addfield(o, r->f, NULL, NULL); + bool ok = upb_oneofdef_addfield(o, r->f, &r->f, NULL); UPB_UNUSED(hd); UPB_ASSERT(ok); @@ -663,9 +663,15 @@ static void *msg_startfield(void *closure, const void *hd) { static bool msg_endfield(void *closure, const void *hd) { upb_descreader *r = closure; upb_msgdef *m = upb_descreader_top(r); + bool ok; UPB_UNUSED(hd); - upb_msgdef_addfield(m, r->f, &r->f, NULL); + /* Oneof fields are added to the msgdef through their oneof, so don't need to + * be added here. */ + if (upb_fielddef_containingoneof(r->f) == NULL) { + ok = upb_msgdef_addfield(m, r->f, &r->f, NULL); + UPB_ASSERT(ok); + } r->f = NULL; return true; } |