From: Andrew M. Kuchling Date: Fri, 29 Sep 2006 17:42:30 +0000 (+0000) Subject: [Backport rev39767 by nnorwitz] X-Git-Tag: v2.4.4c1~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=100e7d77f27e232aa43e84c1c66080a08b651058;p=thirdparty%2FPython%2Fcpython.git [Backport rev39767 by nnorwitz] 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] --- diff --git a/Misc/NEWS b/Misc/NEWS index b066a0d2a18b..4e454bec1ad3 100644 --- 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. diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 43c3ed6f670b..07b38a99612e 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -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 */