util: Fix state leakage in the SortIncludes style verifier
There are cases where the state of a SortIncludes object gets messed up and leaks between invocations/files. This typically happens when a file ends with an include block (dump_block() gets called at the end of __call__). In this case, the state of the class is not reset between files. This bug manifests itself as ghost includes that leak between files when applying the style hooks. This changeset adds a reset at the beginning of the __call__ method which ensures that the class is always in a clean state when processing a new file.
This commit is contained in:
parent
f6f6ae461e
commit
43f1e41c02
1 changed files with 2 additions and 1 deletions
|
@ -72,7 +72,7 @@ class SortIncludes(object):
|
||||||
includes_re = tuple((a, b, re.compile(c)) for a,b,c in includes_re)
|
includes_re = tuple((a, b, re.compile(c)) for a,b,c in includes_re)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.reset()
|
pass
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
# clear all stored headers
|
# clear all stored headers
|
||||||
|
@ -103,6 +103,7 @@ class SortIncludes(object):
|
||||||
prev = l
|
prev = l
|
||||||
|
|
||||||
def __call__(self, lines, filename, language):
|
def __call__(self, lines, filename, language):
|
||||||
|
self.reset()
|
||||||
leading_blank = False
|
leading_blank = False
|
||||||
blanks = 0
|
blanks = 0
|
||||||
block = False
|
block = False
|
||||||
|
|
Loading…
Reference in a new issue