mirror of https://github.com/python/cpython
Patch from SF bug #472956: UMR when there is a syntax error (Neal Norwitz)
perrdetail.token is unitialized when there is a syntax error in a file.
This commit is contained in:
parent
67b2659046
commit
0c156a5130
|
@ -14,6 +14,7 @@ int Py_TabcheckFlag;
|
|||
|
||||
/* Forward */
|
||||
static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int);
|
||||
static void initerr(perrdetail *err_ret);
|
||||
|
||||
/* Parse input coming from a string. Return error code, print some errors. */
|
||||
node *
|
||||
|
@ -28,13 +29,7 @@ PyParser_ParseStringFlags(char *s, grammar *g, int start,
|
|||
{
|
||||
struct tok_state *tok;
|
||||
|
||||
err_ret->error = E_OK;
|
||||
err_ret->filename = NULL;
|
||||
err_ret->lineno = 0;
|
||||
err_ret->offset = 0;
|
||||
err_ret->text = NULL;
|
||||
err_ret->token = -1;
|
||||
err_ret->expected = -1;
|
||||
initerr(err_ret);
|
||||
|
||||
if ((tok = PyTokenizer_FromString(s)) == NULL) {
|
||||
err_ret->error = E_NOMEM;
|
||||
|
@ -68,11 +63,7 @@ PyParser_ParseFileFlags(FILE *fp, char *filename, grammar *g, int start,
|
|||
{
|
||||
struct tok_state *tok;
|
||||
|
||||
err_ret->error = E_OK;
|
||||
err_ret->filename = filename;
|
||||
err_ret->lineno = 0;
|
||||
err_ret->offset = 0;
|
||||
err_ret->text = NULL;
|
||||
initerr(err_ret);
|
||||
|
||||
if ((tok = PyTokenizer_FromFile(fp, ps1, ps2)) == NULL) {
|
||||
err_ret->error = E_NOMEM;
|
||||
|
@ -185,3 +176,15 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
|
|||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void
|
||||
initerr(perrdetail *err_ret)
|
||||
{
|
||||
err_ret->error = E_OK;
|
||||
err_ret->filename = NULL;
|
||||
err_ret->lineno = 0;
|
||||
err_ret->offset = 0;
|
||||
err_ret->text = NULL;
|
||||
err_ret->token = -1;
|
||||
err_ret->expected = -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue