]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport rev. 51669 by brett.cannon]
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 3 Oct 2006 13:04:29 +0000 (13:04 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 3 Oct 2006 13:04:29 +0000 (13:04 +0000)
Make sure memory is properly cleaned up in file_init.

Backport candidate.

Misc/NEWS
Objects/fileobject.c

index 3b8e66d571a5a302833c61a9fdb6ae65ede0b0f9..fb20fa43a5dc693e6b55c2cc9fde6f4e0267eb0a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -21,6 +21,8 @@ Core and builtins
 - Bug #1365916: Fix an int/long mismatch in the sorted() built-in.
 
 - Fix memory leak of coding spec in Parser/tokenizer.c.
+
+- Fix memory leak in file_init.
  
 - Overflow checking code in integer division ran afoul of new gcc
   optimizations.  Changed to be more standard-conforming.
@@ -54,7 +56,7 @@ Core and builtins
 
 - Patch #1488312, Fix memory alignment problem on SPARC in unicode
 
-- Fixed a few bugs on cjkcodecs:
+- Fixed a few bugs in cjkcodecs:
   - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly.
   - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312
     codepoints to conform the standard.
index d7a06942e015f1d6fa557564828a52266bf50a2b..16499eec9f0bd408814c335887bee7edda9d8bea 100644 (file)
@@ -1878,7 +1878,7 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds)
                 /* We parse again to get the name as a PyObject */
                 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist,
                     &o_name, &mode, &bufsize))
-                        return -1;
+                        goto Error;
 
                if (fill_file_fields(foself, NULL, o_name, mode,
                                     fclose) == NULL)