Memory leak fix handling empty /// doxygen comments
diff --git a/CHANGES.current b/CHANGES.current
index 06f214c..db2d8a9 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,8 @@
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 4c1a038..19a0138 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -428,6 +428,7 @@
/* 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 @@
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 @@
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));