Fixed broken submsg support in upb_streamdata.

pull/13171/head
Joshua Haberman 15 years ago
parent af9d691a34
commit b77db14646
  1. 10
      core/upb_stream.c

@ -14,11 +14,14 @@
void upb_streamdata(upb_src *src, upb_sink *sink, upb_status *status) { void upb_streamdata(upb_src *src, upb_sink *sink, upb_status *status) {
upb_fielddef *f; upb_fielddef *f;
upb_string *str = NULL; upb_string *str = NULL;
int depth = 0;
while(1) {
while((f = upb_src_getdef(src)) != NULL) { while((f = upb_src_getdef(src)) != NULL) {
CHECKSINK(upb_sink_putdef(sink, f)); CHECKSINK(upb_sink_putdef(sink, f));
if(upb_issubmsg(f)) { if(upb_issubmsg(f)) {
// We always recurse into submessages, but the putdef above already told upb_src_startmsg(src);
// the sink that. upb_sink_startmsg(sink);
++depth;
} else if(upb_isstring(f)) { } else if(upb_isstring(f)) {
str = upb_string_tryrecycle(str); str = upb_string_tryrecycle(str);
CHECKSRC(upb_src_getstr(src, str)); CHECKSRC(upb_src_getstr(src, str));
@ -32,6 +35,9 @@ void upb_streamdata(upb_src *src, upb_sink *sink, upb_status *status) {
} }
// If we're not EOF now, the loop terminated due to an error. // If we're not EOF now, the loop terminated due to an error.
CHECKSRC(upb_src_eof(src)); CHECKSRC(upb_src_eof(src));
if (depth == 0) break;
--depth;
}
return; return;
src_err: src_err:

Loading…
Cancel
Save