From d2389ba261e7e49a14f405be97c3ee0b689ce567 Mon Sep 17 00:00:00 2001 From: Anna R Date: Tue, 7 Jan 2020 16:11:36 -0800 Subject: [PATCH] Add correctness asserts to upb_addmsg --- upb/decode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/upb/decode.c b/upb/decode.c index 4f07988595..4672b1b84b 100644 --- a/upb/decode.c +++ b/upb/decode.c @@ -249,6 +249,10 @@ static upb_msg *upb_addmsg(upb_decframe *frame, upb_msg *submsg; upb_array *arr = upb_getorcreatearr(frame, field); + UPB_ASSERT(field->label == UPB_LABEL_REPEATED); + UPB_ASSERT(field->descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE || + field->descriptortype == UPB_DESCRIPTOR_TYPE_GROUP); + *subm = frame->layout->submsgs[field->submsg_index]; submsg = upb_msg_new(*subm, frame->state->arena); CHK(submsg);