Fix pydoc null pointer dereference with missing arg type
Processing doxygen @param comments for a parameter whose name did not appear in the function declaration would cause a segfault due to a null pointer dereference. Adding test cases for both variadic function (no specified arguments) and @param comment that references an argument that is not named in the function prototype. Both of these cases previously segfaulted.
This commit is contained in:
parent
e4c38f0f67
commit
f99eb0058b
4 changed files with 35 additions and 5 deletions
|
|
@ -107,6 +107,20 @@ double Atan2(double y, double x)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Test variadic function
|
||||||
|
* @param ... extra args
|
||||||
|
*/
|
||||||
|
void function8(...) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Test unnamed argument
|
||||||
|
* @param baz Description of baz
|
||||||
|
*/
|
||||||
|
void function9(int) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment at the end of file should be ignored.
|
* Comment at the end of file should be ignored.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,13 @@ public class doxygen_basic_translate_runme {
|
||||||
" @param x Horizontal coordinate.\n" +
|
" @param x Horizontal coordinate.\n" +
|
||||||
" @return Arc tangent of <code>y/x</code>.\n" +
|
" @return Arc tangent of <code>y/x</code>.\n" +
|
||||||
"");
|
"");
|
||||||
|
wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function8()",
|
||||||
|
" Test variadic function\n" +
|
||||||
|
"");
|
||||||
|
|
||||||
|
wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function9(int)",
|
||||||
|
" Test unnamed argument\n" +
|
||||||
|
"");
|
||||||
|
|
||||||
// and ask the parser to check comments for us
|
// and ask the parser to check comments for us
|
||||||
System.exit(parser.check(wantedComments));
|
System.exit(parser.check(wantedComments));
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,16 @@ Test for a parameter with difficult type
|
||||||
:type a: :py:class:`Shape`
|
:type a: :py:class:`Shape`
|
||||||
:param a: Very strange param"""
|
:param a: Very strange param"""
|
||||||
)
|
)
|
||||||
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function8),
|
||||||
|
"""\
|
||||||
|
Test variadic function
|
||||||
|
:param ...: extra args"""
|
||||||
|
)
|
||||||
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function9),
|
||||||
|
"""\
|
||||||
|
Test unnamed argument
|
||||||
|
:param baz: Description of baz"""
|
||||||
|
)
|
||||||
|
|
||||||
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.Atan2),
|
comment_verifier.check(inspect.getdoc(doxygen_basic_translate.Atan2),
|
||||||
"""\
|
"""\
|
||||||
|
|
|
||||||
|
|
@ -418,11 +418,10 @@ std::string PyDocConverter::getParamType(std::string param) {
|
||||||
ParmList *plist = CopyParmList(Getattr(currentNode, "parms"));
|
ParmList *plist = CopyParmList(Getattr(currentNode, "parms"));
|
||||||
for (Parm *p = plist; p; p = nextSibling(p)) {
|
for (Parm *p = plist; p; p = nextSibling(p)) {
|
||||||
String *pname = Getattr(p, "name");
|
String *pname = Getattr(p, "name");
|
||||||
if (Char(pname) != param)
|
if (pname && Char(pname) == param) {
|
||||||
continue;
|
type = getPyDocType(p, pname);
|
||||||
|
break;
|
||||||
type = getPyDocType(p, pname);
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Delete(plist);
|
Delete(plist);
|
||||||
return type;
|
return type;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue