Skip to content

Commit 3328ff7

Browse files
masahir0ySasha Levin
authored and
Sasha Levin
committed
kconfig: fix infinite loop when expanding a macro at the end of file
[ Upstream commit af8bbce ] A macro placed at the end of a file with no newline causes an infinite loop. [Test Kconfig] $(info,hello) \ No newline at end of file I realized that flex-provided input() returns 0 instead of EOF when it reaches the end of a file. Fixes: 104daea ("kconfig: reference environment variables directly and remove 'option env='") Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent afce135 commit 3328ff7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/kconfig/lexer.l

+5-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,11 @@ static char *expand_token(const char *in, size_t n)
302302
new_string();
303303
append_string(in, n);
304304

305-
/* get the whole line because we do not know the end of token. */
306-
while ((c = input()) != EOF) {
305+
/*
306+
* get the whole line because we do not know the end of token.
307+
* input() returns 0 (not EOF!) when it reachs the end of file.
308+
*/
309+
while ((c = input()) != 0) {
307310
if (c == '\n') {
308311
unput(c);
309312
break;

0 commit comments

Comments
 (0)