summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2010-07-19 09:48:08 -0700
committerJoshua Haberman <joshua@reverberate.org>2010-07-19 09:48:08 -0700
commitf6bc538f31d705f58aceac38726b9515291db24f (patch)
tree3778879263039992382ba1712335f85f6e2c6ca3
parent904a79cec3e77efc0253e4412ab766d602ae126d (diff)
Prevent abort() if add_descriptorproto() is called twice.
-rw-r--r--core/upb_def.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/upb_def.c b/core/upb_def.c
index 0d97982..1feaf9d 100644
--- a/core/upb_def.c
+++ b/core/upb_def.c
@@ -1023,7 +1023,16 @@ static upb_src *upb_baredecoder_src(upb_baredecoder *d)
void upb_symtab_add_descriptorproto(upb_symtab *symtab)
{
- // TODO: allow upb_strings to be static or on the stack.
+ // For the moment we silently decline to perform the operation if the symbols
+ // already exist in the symtab. Revisit this when we have a better story
+ // about whether syms in a table can be replaced.
+ upb_def *def = upb_symtab_lookup(
+ symtab, UPB_STRLIT("google.protobuf.FileDescriptorSet"));
+ if(def) {
+ upb_def_unref(def);
+ return;
+ }
+
upb_baredecoder *decoder = upb_baredecoder_new(&descriptor_str);
upb_status status = UPB_STATUS_INIT;
upb_symtab_addfds(symtab, upb_baredecoder_src(decoder), &status);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback