From e69ec2d046626fa2079d460aab469d04256182cd Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 24 Oct 2019 12:52:10 -0700 Subject: write_make_conf: fix infinite loop (bug 698470) Fixes: 42238f4ff13a ("write_make_conf: support multi-line GENTOO_MIRRORS (bug 543814)") Bug: https://bugs.gentoo.org/698470 Signed-off-by: Zac Medico --- mirrorselect/configs.py | 2 ++ tests/test_write_make_conf.py | 1 + 2 files changed, 3 insertions(+) diff --git a/mirrorselect/configs.py b/mirrorselect/configs.py index df718f6..4cba14f 100644 --- a/mirrorselect/configs.py +++ b/mirrorselect/configs.py @@ -81,6 +81,8 @@ def write_make_conf(output, config_path, var, mirror_string): lex.quotes = "\"'" while True: key = lex.get_token() + if key is None: + break if key == var: begin_line = lex.lineno diff --git a/tests/test_write_make_conf.py b/tests/test_write_make_conf.py index 3dedd93..fb84978 100644 --- a/tests/test_write_make_conf.py +++ b/tests/test_write_make_conf.py @@ -23,6 +23,7 @@ class WriteMakeConfTestCase(unittest.TestCase): ('\n{}="foo \\\nbar"\n'.format(var), '\n{}\n'.format(mirror_string)), ('\n\n{}="foo \\\nbar"\n'.format(var), '\n\n{}\n'.format(mirror_string)), ('\n\n{}="foo \\\nbar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'.format(mirror_string)), + ('', '{}\n'.format(mirror_string)), ) for make_conf, expected_result in cases: -- cgit v1.2.3-65-gdbad