Merge branch 'doxy/segfault'
* doxy/segfault: Add iterator safety check in DoxygenParser::parse Doxygen comment parsing fix for empty lines in code/verbatim blocks
This commit is contained in:
commit
42f5e2da41
8 changed files with 32 additions and 1 deletions
|
|
@ -57,6 +57,8 @@ void function3(int a, int b)
|
|||
* \warning This may not work as expected
|
||||
* \code
|
||||
* int main() { while(true); }
|
||||
*
|
||||
* // Test blank line in code block
|
||||
* \endcode
|
||||
* \endif
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ void function3(int a, int b)
|
|||
* \warning This may not work as expected
|
||||
* \code
|
||||
* int main() { while(true); }
|
||||
*
|
||||
* // Test blank line in code block
|
||||
* \endcode
|
||||
* \endif
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ public class doxygen_basic_translate_runme {
|
|||
" \n" +
|
||||
" {@code \n" +
|
||||
"int main() { while(true); } \n" +
|
||||
"\n" +
|
||||
"// Test blank line in code block \n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" \n" +
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ public class doxygen_basic_translate_style2_runme {
|
|||
" \n" +
|
||||
" {@code \n" +
|
||||
"int main() { while(true); } \n" +
|
||||
"\n" +
|
||||
"// Test blank line in code block \n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" \n" +
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ Warning: This may not work as expected
|
|||
.. code-block:: c++
|
||||
|
||||
int main() { while(true); }
|
||||
|
||||
// Test blank line in code block
|
||||
}"""
|
||||
)
|
||||
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5),
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ Warning: This may not work as expected
|
|||
.. code-block:: c++
|
||||
|
||||
int main() { while(true); }
|
||||
|
||||
// Test blank line in code block
|
||||
}"""
|
||||
)
|
||||
comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5),
|
||||
|
|
|
|||
|
|
@ -289,6 +289,18 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(const TokenList &to
|
|||
TokenListCIt endOfParagraph = m_tokenListIt;
|
||||
|
||||
while (endOfParagraph != tokList.end()) {
|
||||
// If \code or \verbatim is encountered within a paragraph, then
|
||||
// go all the way to the end of that command, since the content
|
||||
// could contain empty lines that would appear to be paragraph
|
||||
// ends:
|
||||
if (endOfParagraph->m_tokenType == COMMAND &&
|
||||
(endOfParagraph->m_tokenString == "code" ||
|
||||
endOfParagraph->m_tokenString == "verbatim")) {
|
||||
const string theCommand = endOfParagraph->m_tokenString;
|
||||
endOfParagraph = getEndCommand("end" + theCommand, tokList);
|
||||
endOfParagraph++; // Move after the end command
|
||||
return endOfParagraph;
|
||||
}
|
||||
if (endOfParagraph->m_tokenType == END_LINE) {
|
||||
endOfParagraph++;
|
||||
if (endOfParagraph != tokList.end()
|
||||
|
|
@ -959,7 +971,9 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, const Token
|
|||
std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string";
|
||||
DoxygenEntityList aNewList;
|
||||
|
||||
while (m_tokenListIt != endParsingIndex) {
|
||||
// Less than check (instead of not equal) is a safeguard in case the
|
||||
// iterator is incremented past the end
|
||||
while (m_tokenListIt < endParsingIndex) {
|
||||
|
||||
Token currToken = *m_tokenListIt;
|
||||
|
||||
|
|
@ -976,6 +990,10 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, const Token
|
|||
addCommand(currPlainstringCommandType, tokList, aNewList);
|
||||
}
|
||||
|
||||
// If addCommand above misbehaves, it can move the iterator past endParsingIndex
|
||||
if (m_tokenListIt > endParsingIndex)
|
||||
printListError(WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE, "Unexpected iterator value in DoxygenParser::parse");
|
||||
|
||||
if (endParsingIndex != tokList.end() && m_tokenListIt == tokList.end()) {
|
||||
// this could happen if we can't reach the original endParsingIndex
|
||||
printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of Doxygen comment encountered.");
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@
|
|||
#define WARN_DOXYGEN_HTML_ERROR 563
|
||||
#define WARN_DOXYGEN_COMMAND_ERROR 564
|
||||
#define WARN_DOXYGEN_UNKNOWN_CHARACTER 565
|
||||
#define WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE 566
|
||||
|
||||
/* -- Reserved (600-799) -- */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue