]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport r51222 | neal.norwitz -- if you hack the code to set r=NULL,
authorAndrew M. Kuchling <amk@amk.ca>
Thu, 5 Oct 2006 19:32:52 +0000 (19:32 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Thu, 5 Oct 2006 19:32:52 +0000 (19:32 +0000)
 you find that Python does print "MemoryError".  There's no traceback
 and no indication of which line of code is responsible, but it's
 better than a segfault.]

Handle NULL nodes while parsing.  I'm not entirely sure this is correct.
There might be something else that needs to be done to setup the error.

Klocwork #295.

Parser/parsetok.c

index 1fa9739308c4597279fe26e3d76f92286b8cb2fa..112363fee91db561306daa95a2ec483ca281b563 100644 (file)
@@ -197,6 +197,11 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
                }
        } else if (tok->encoding != NULL) {
                node* r = PyNode_New(encoding_decl);
+               if (!r) {
+                       err_ret->error = E_NOMEM;
+                       n = NULL;
+                       goto done;
+               }
                r->n_str = tok->encoding;
                r->n_nchildren = 1;
                r->n_child = n;
@@ -204,6 +209,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
                n = r;
        }
 
+done:
        PyTokenizer_Free(tok);
 
        return n;