From b72ed3b97a41df5f6690c8d5c966fa33e75213d5 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Fri, 12 Jun 2015 15:23:56 -0700 Subject: Fix for stack overflow for cyclic defs. Fixes this bug that came up in the Ruby extension: https://github.com/google/protobuf/issues/425 --- tests/test_def.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/test_def.c') 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(); -- cgit v1.2.3