There was an error while loading. Please reload this page.
1 parent cd280fb commit 1ee99d3Copy full SHA for 1ee99d3
2 files changed
Parser/tokenizer.c
@@ -128,8 +128,10 @@ tok_new(void)
128
tok->read_coding_spec = 0;
129
tok->issued_encoding_warning = 0;
130
tok->encoding = NULL;
131
+#ifndef PGEN
132
tok->decoding_readline = NULL;
133
tok->decoding_buffer = NULL;
134
+#endif
135
return tok;
136
}
137
@@ -225,8 +227,8 @@ get_coding_spec(const char *s, int size)
225
227
char* r = new_string(begin, t - begin);
226
228
char* q = get_normal_name(r);
229
if (r != q) {
- assert(strlen(r) >= strlen(q));
- strcpy(r, q);
230
+ PyMem_DEL(r);
231
+ r = new_string(q, strlen(q));
232
233
return r;
234
@@ -584,8 +586,10 @@ PyTokenizer_Free(struct tok_state *tok)
584
586
{
585
587
if (tok->encoding != NULL)
588
PyMem_DEL(tok->encoding);
589
590
Py_XDECREF(tok->decoding_readline);
591
Py_XDECREF(tok->decoding_buffer);
592
593
if (tok->fp != NULL && tok->buf != NULL)
594
PyMem_DEL(tok->buf);
595
PyMem_DEL(tok);
Parser/tokenizer.h
@@ -45,8 +45,10 @@ struct tok_state {
45
int read_coding_spec; /* whether 'coding:...' has been read */
46
int issued_encoding_warning; /* whether non-ASCII warning was issued */
47
char *encoding;
48
49
PyObject *decoding_readline; /* codecs.open(...).readline */
50
PyObject *decoding_buffer;
51
52
const char* enc;
53
const char* str;
54
};
0 commit comments