From ae1e736c1b2aaefa7664a6d64829dba0c2ca72e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 07:47:53 +0000 Subject: [PATCH] Memory leak fix handling empty /// doxygen comments --- CHANGES.current | 2 ++ Source/CParse/cscanner.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 06f214c52..db2d8a918 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -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) =========================== +2020-01-16: mcfarljm + #1632 #1659 Fix newline handling for doxygen "///" comments 2020-01-14: mcfarljm #1608 Improve doxygen support. diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 4c1a038fb..19a013803 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -428,6 +428,7 @@ static int yylook(void) { /* Concatenate or skip all consecutive comments at once. */ do { String *cmt = Scanner_text(scan); + String *cmt_modified = 0; char *loc = Char(cmt); if ((strncmp(loc, "/*@SWIG", 7) == 0) && (loc[Len(cmt)-3] == '@')) { Scanner_locator(scan, cmt); @@ -439,9 +440,9 @@ static int yylook(void) { slashStyle = 1; if (Len(cmt) == 3) { /* Modify to make length=4 to ensure that the empty comment does - get processed to preserve the newlines in the original - comments. */ - cmt = NewStringf("%s ", cmt); + get processed to preserve the newlines in the original comments. */ + cmt_modified = NewStringf("%s ", cmt); + cmt = cmt_modified; loc = Char(cmt); } } @@ -492,6 +493,7 @@ static int yylook(void) { do { tok = Scanner_token(scan); } while (tok == SWIG_TOKEN_ENDLINE); + Delete(cmt_modified); } while (tok == SWIG_TOKEN_COMMENT); Scanner_pushtoken(scan, tok, Scanner_text(scan));