From f729e862e9490752aeccf5ef218b3d381c1b5738 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Mon, 12 Jan 2015 15:29:44 +0100 Subject: Fixing bug where empty tagless docstring in Natspec would result in infinite loop --- SolidityNatspecJSON.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'SolidityNatspecJSON.cpp') diff --git a/SolidityNatspecJSON.cpp b/SolidityNatspecJSON.cpp index f6a33247..7edb97a7 100644 --- a/SolidityNatspecJSON.cpp +++ b/SolidityNatspecJSON.cpp @@ -510,6 +510,19 @@ BOOST_AUTO_TEST_CASE(dev_title_at_function_error) BOOST_CHECK_THROW(checkNatspec(sourceCode, natspec, false), DocstringParsingError); } +// test for bug where having no tags in docstring would cause infinite loop +BOOST_AUTO_TEST_CASE(natspec_no_tags) +{ + char const* sourceCode = "contract test {\n" + " /// I do something awesome\n" + " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" + "}\n"; + + char const* natspec = "{\"methods\": {}}"; + + checkNatspec(sourceCode, natspec, false); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3