]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/scripting/bin: Fix resource leak
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 27 Apr 2023 03:15:03 +0000 (15:15 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 5 May 2023 02:54:31 +0000 (02:54 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/scripting/bin/gen_ntstatus.py

index b4a9bfc1586890006ebc5c2e7ebfa28ecaf12145..9b04165ed815347a2638da4d489a352c8075c310 100755 (executable)
@@ -126,9 +126,8 @@ def main ():
         sys.exit()
 
     # read in the data
-    file_contents = io.open(input_file, "rt", encoding='utf8')
-
-    errors = parseErrorDescriptions(file_contents, False, transformErrorName)
+    with io.open(input_file, "rt", encoding='utf8') as file_contents:
+        errors = parseErrorDescriptions(file_contents, False, transformErrorName)
 
     print("writing new header file: %s" % gen_headerfile_name)
     out_file = io.open(gen_headerfile_name, "wt", encoding='utf8')