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:
Guido van Rossum 2001-10-20 14:27:56 +00:00
parent 67b2659046
commit 0c156a5130
1 changed files with 15 additions and 12 deletions

View File

@ -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;
}