diff options
author | Joshua Haberman <joshua@reverberate.org> | 2011-08-10 19:46:08 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2011-08-10 19:46:08 -0700 |
commit | 336268b3d7e8860e86171650882d0a4f7d62ecfd (patch) | |
tree | d807ee52068134c3a7bd884d0efa558ce51bddb1 /upb | |
parent | be7457245594fdc56ee23306eb6e3962f7333fc7 (diff) |
Fixed a few memory leaks and Makefile tweaks.
Diffstat (limited to 'upb')
-rw-r--r-- | upb/def.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -226,6 +226,11 @@ static void upb_fielddef_free(upb_fielddef *f) { if (upb_isstring(f)) { free(upb_value_getptr(f->defaultval)); } + if (f->def) { + // We own a ref on the subdef iff we are not part of a msgdef. + assert((f->msgdef == NULL) == (upb_dyncast_unresolveddef(f->def) != NULL)); + if (f->msgdef == NULL) upb_def_unref(f->def); + } free(f->name); free(f); } @@ -305,6 +310,7 @@ bool upb_fielddef_setnumber(upb_fielddef *f, int32_t number) { bool upb_fielddef_setname(upb_fielddef *f, const char *name) { assert(f->msgdef == NULL); + free(f->name); f->name = strdup(name); return true; } |