Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kconfig: fix infinite loop when expanding a macro at the end of file

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: 104daea149c4 ("kconfig: reference environment variables directly and remove 'option env='")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+5 -2
+5 -2
scripts/kconfig/lexer.l
··· 303 303 new_string(); 304 304 append_string(in, n); 305 305 306 - /* get the whole line because we do not know the end of token. */ 307 - while ((c = input()) != EOF) { 306 + /* 307 + * get the whole line because we do not know the end of token. 308 + * input() returns 0 (not EOF!) when it reachs the end of file. 309 + */ 310 + while ((c = input()) != 0) { 308 311 if (c == '\n') { 309 312 unput(c); 310 313 break;