]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport rev39767 by nnorwitz]
authorAndrew M. Kuchling <amk@amk.ca>
Fri, 29 Sep 2006 17:42:30 +0000 (17:42 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Fri, 29 Sep 2006 17:42:30 +0000 (17:42 +0000)
Free coding spec (cs) if there was an error to prevent mem leak.
Maybe backport candidate.

[Bugfix seems applicable to 2.4 to me. --amk]

Misc/NEWS
Parser/tokenizer.c

index b066a0d2a18bfd9898abc8cb08a9bb6509a8ac5f..4e454bec1ad3ce4e022f6930fef2ba2c797b8095 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.4.4c1?
 Core and builtins
 -----------------
 
+- Fix memory leak of coding spec in Parser/tokenizer.c.
 - Overflow checking code in integer division ran afoul of new gcc
   optimizations.  Changed to be more standard-conforming.
 
index 43c3ed6f670bc5827201fe9ce264320f9581d5e2..07b38a99612e6ec2f1788daae4309239d83db3a0 100644 (file)
@@ -277,11 +277,14 @@ check_coding_spec(const char* line, int size, struct tok_state *tok,
                                        tok->encoding = cs;
                                        tok->decoding_state = -1;
                                }
+                               else
+                                       PyMem_DEL(cs);
 #else
                                 /* Without Unicode support, we cannot
                                    process the coding spec. Since there
                                    won't be any Unicode literals, that
                                    won't matter. */
+                               PyMem_DEL(cs);
 #endif
                        }
                } else {        /* then, compare cs with BOM */