summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-06-12 15:23:56 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-06-12 15:23:56 -0700
commitb72ed3b97a41df5f6690c8d5c966fa33e75213d5 (patch)
tree55e8273516167e0e233f15555279cd2e55021941 /tests
parent21d32dfe3dc3ee5b924520bef6d88f6b266fe1b1 (diff)
Fix for stack overflow for cyclic defs.
Fixes this bug that came up in the Ruby extension: https://github.com/google/protobuf/issues/425
Diffstat (limited to 'tests')
-rw-r--r--tests/test_def.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_def.c b/tests/test_def.c
index 4f9fcff..c33d584 100644
--- a/tests/test_def.c
+++ b/tests/test_def.c
@@ -246,6 +246,18 @@ static void test_replacement() {
upb_symtab_unref(s, &s);
}
+static void test_cycles_in_replacement() {
+ upb_symtab *s = upb_symtab_new(&s);
+ upb_msgdef *m = upb_msgdef_newnamed("M", &s);
+ upb_status status = UPB_STATUS_INIT;
+
+ upb_msgdef_addfield(m, newfield("m", 1, UPB_TYPE_MESSAGE,
+ UPB_LABEL_OPTIONAL, ".M", &s),
+ &s, NULL);
+ ASSERT_STATUS(upb_symtab_add(s, (upb_def**)&m, 1, &s, &status), &status);
+ ASSERT_STATUS(upb_symtab_add(s, NULL, 0, &s, &status), &status);
+}
+
static void test_freeze_free() {
bool ok;
@@ -459,6 +471,7 @@ int run_tests(int argc, char *argv[]) {
test_fielddef();
test_fielddef_unref();
test_replacement();
+ test_cycles_in_replacement();
test_freeze_free();
test_partial_freeze();
test_noreftracking();
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback