Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src



Module Name:    src
Committed By:   rillig
Date:           Fri Nov 19 18:52:33 UTC 2021

Modified Files:
        src/tests/usr.bin/indent: fmt_decl.c
        src/usr.bin/indent: lexi.c

Log Message:
indent: fix lost function name (since 2019-04-04)

When indent searched for an identifier followed by a '(', to see whether
the identifier is a function name, it didn't care that the input buffer
could be resized due to a long line, which had made the pointer 'tp'
invalid.  Fix this by stopping the search at the end of the line.  A
better approach would be to have an unlimited lookahead buffer for
situations like these.  The code that deals with character input has
already been extracted to io.c, so it's possible to implement that now.

While here, fix another access to undefined memory, after the loop.

There is still the issue of overwriting procname[0] with a blank, which
results in inconsistent formatting depending on the function name,
probably another case of accessing undefined memory, although the
results have been reproducible, but that may have been pure luck.

The formatted code looks clearly broken, but that's still better than
losing a token and destroying the whole file.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index