Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0d5faa

Browse files
committed
Free coding spec (cs) if there was an error to prevent mem leak. Maybe backport candidate
1 parent 1e8659b commit c0d5faa

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Parser/tokenizer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,14 @@ check_coding_spec(const char* line, int size, struct tok_state *tok,
277277
tok->encoding = cs;
278278
tok->decoding_state = -1;
279279
}
280+
else
281+
PyMem_DEL(cs);
280282
#else
281283
/* Without Unicode support, we cannot
282284
process the coding spec. Since there
283285
won't be any Unicode literals, that
284286
won't matter. */
287+
PyMem_DEL(cs);
285288
#endif
286289
}
287290
} else { /* then, compare cs with BOM */

0 commit comments

Comments
 (0)