Properly free dynamic memory that has not been reused during parsing.

pull/13171/head
Joshua Haberman 16 years ago
parent a022e6ebdb
commit d05eac2890
  1. 13
      src/upb_msg.c

@ -245,8 +245,17 @@ static void end_cb(void *udata)
{
struct upb_msg_parser *mp = udata;
struct upb_msg *msg = mp->top->msg;
/* TODO: free any remaining dynamic storage that was not reused. */
(void)msg;
struct upb_msgdef *def = msg->def;
// Free any remaining dynamic storage we did not reuse.
for(uint32_t i = 0; i < def->num_fields; i++) {
struct upb_msg_fielddef *f = &def->fields[i];
union upb_value_ptr p = upb_msg_getptr(msg, f);
if(upb_msg_isset(msg, f) || !upb_field_ismm(f) || !*p.msg) continue;
union upb_mmptr mmptr = upb_mmptr_read(p, f->type);
upb_mm_unref(mmptr, f->type);
}
mp->top--;
}

Loading…
Cancel
Save