From 100e7d77f27e232aa43e84c1c66080a08b651058 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Fri, 29 Sep 2006 17:42:30 +0000 Subject: [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] --- Misc/NEWS | 2 ++ Parser/tokenizer.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index b066a0d..4e454be 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 43c3ed6..07b38a9 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 */ -- cgit v0.12