summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-10-20 14:27:56 (GMT)
committerGuido van Rossum <guido@python.org>2001-10-20 14:27:56 (GMT)
commit0c156a5130905c45aa45b0a3d9faa65923d92bad (patch)
treeca05e94c4824b59fb00abbf17f40a55c2b66c492 /Parser
parent67b2659046b624dcd84c09a3912caf33eeb53733 (diff)
downloadcpython-0c156a5130905c45aa45b0a3d9faa65923d92bad.zip
cpython-0c156a5130905c45aa45b0a3d9faa65923d92bad.tar.gz
cpython-0c156a5130905c45aa45b0a3d9faa65923d92bad.tar.bz2
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.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parsetok.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 386b82f..bdd51f3 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -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;
+}