Skip to content

Commit

Permalink
fix memory leak in ColorOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
CoffeeTableEspresso committed Sep 25, 2022
1 parent 113b293 commit 484c5a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions asdl/format.py
Expand Up @@ -348,6 +348,7 @@ def _PrintRecord(self, node, f, indent):
s, num_chars = single_f.GetRaw() # extra unpacking for mycpp
f.WriteRaw((s, num_chars))
else:
cast(mylib.BufWriter, single_f.f).reset()
f.write('\n')
self.PrintNode(val, f, indent+INDENT+INDENT)

Expand Down Expand Up @@ -376,6 +377,8 @@ def PrintNode(self, node, f, indent):
s, num_chars = single_f.GetRaw() # extra unpacking for mycpp
f.WriteRaw((s, num_chars))
return
else:
cast(mylib.BufWriter, single_f.f).reset()

UP_node = node # for mycpp
tag = node.tag_()
Expand Down
1 change: 1 addition & 0 deletions mycpp/mylib.pyi
Expand Up @@ -30,6 +30,7 @@ class Writer:
class BufWriter(Writer):
def write(self, s: str) -> None: ...
def getvalue(self) -> str: ...
def reset(self) -> None: ...

def Stdout() -> Writer: ...

Expand Down

0 comments on commit 484c5a9

Please sign in to comment.