Memory leak fix handling empty /// doxygen comments

This commit is contained in:
William S Fulton 2020-01-16 07:47:53 +00:00
commit ae1e736c1b
2 changed files with 7 additions and 3 deletions

View file

@ -7,6 +7,8 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.0.2 (in progress) Version 4.0.2 (in progress)
=========================== ===========================
2020-01-16: mcfarljm
#1632 #1659 Fix newline handling for doxygen "///" comments
2020-01-14: mcfarljm 2020-01-14: mcfarljm
#1608 Improve doxygen support. #1608 Improve doxygen support.

View file

@ -428,6 +428,7 @@ static int yylook(void) {
/* Concatenate or skip all consecutive comments at once. */ /* Concatenate or skip all consecutive comments at once. */
do { do {
String *cmt = Scanner_text(scan); String *cmt = Scanner_text(scan);
String *cmt_modified = 0;
char *loc = Char(cmt); char *loc = Char(cmt);
if ((strncmp(loc, "/*@SWIG", 7) == 0) && (loc[Len(cmt)-3] == '@')) { if ((strncmp(loc, "/*@SWIG", 7) == 0) && (loc[Len(cmt)-3] == '@')) {
Scanner_locator(scan, cmt); Scanner_locator(scan, cmt);
@ -439,9 +440,9 @@ static int yylook(void) {
slashStyle = 1; slashStyle = 1;
if (Len(cmt) == 3) { if (Len(cmt) == 3) {
/* Modify to make length=4 to ensure that the empty comment does /* Modify to make length=4 to ensure that the empty comment does
get processed to preserve the newlines in the original get processed to preserve the newlines in the original comments. */
comments. */ cmt_modified = NewStringf("%s ", cmt);
cmt = NewStringf("%s ", cmt); cmt = cmt_modified;
loc = Char(cmt); loc = Char(cmt);
} }
} }
@ -492,6 +493,7 @@ static int yylook(void) {
do { do {
tok = Scanner_token(scan); tok = Scanner_token(scan);
} while (tok == SWIG_TOKEN_ENDLINE); } while (tok == SWIG_TOKEN_ENDLINE);
Delete(cmt_modified);
} while (tok == SWIG_TOKEN_COMMENT); } while (tok == SWIG_TOKEN_COMMENT);
Scanner_pushtoken(scan, tok, Scanner_text(scan)); Scanner_pushtoken(scan, tok, Scanner_text(scan));