Skip to content

Commit ae1e736

Browse files
committed
Memory leak fix handling empty /// doxygen comments
1 parent 55d36e3 commit ae1e736

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGES.current

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
77
Version 4.0.2 (in progress)
88
===========================
99

10+
2020-01-16: mcfarljm
11+
#1632 #1659 Fix newline handling for doxygen "///" comments
1012

1113
2020-01-14: mcfarljm
1214
#1608 Improve doxygen support.

Source/CParse/cscanner.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ static int yylook(void) {
428428
/* Concatenate or skip all consecutive comments at once. */
429429
do {
430430
String *cmt = Scanner_text(scan);
431+
String *cmt_modified = 0;
431432
char *loc = Char(cmt);
432433
if ((strncmp(loc, "/*@SWIG", 7) == 0) && (loc[Len(cmt)-3] == '@')) {
433434
Scanner_locator(scan, cmt);
@@ -439,9 +440,9 @@ static int yylook(void) {
439440
slashStyle = 1;
440441
if (Len(cmt) == 3) {
441442
/* Modify to make length=4 to ensure that the empty comment does
442-
get processed to preserve the newlines in the original
443-
comments. */
444-
cmt = NewStringf("%s ", cmt);
443+
get processed to preserve the newlines in the original comments. */
444+
cmt_modified = NewStringf("%s ", cmt);
445+
cmt = cmt_modified;
445446
loc = Char(cmt);
446447
}
447448
}
@@ -492,6 +493,7 @@ static int yylook(void) {
492493
do {
493494
tok = Scanner_token(scan);
494495
} while (tok == SWIG_TOKEN_ENDLINE);
496+
Delete(cmt_modified);
495497
} while (tok == SWIG_TOKEN_COMMENT);
496498

497499
Scanner_pushtoken(scan, tok, Scanner_text(scan));

0 commit comments

Comments
 (0)