]> granicus.if.org Git - python/commitdiff
Properly handle a NULL returned from PyArena_New().
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 11 Sep 2006 04:06:23 +0000 (04:06 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 11 Sep 2006 04:06:23 +0000 (04:06 +0000)
Klocwork #364.  Will port to head.

Python/import.c

index 5af365187ec5fc8ee6d4db9005a1036e64da9dee..390f9e3292f762fd98612e23fcdbd7cc7ee04ab1 100644 (file)
@@ -796,14 +796,16 @@ parse_source_module(const char *pathname, FILE *fp)
 {
        PyCodeObject *co = NULL;
        mod_ty mod;
-        PyArena *arena = PyArena_New();
+       PyArena *arena = PyArena_New();
+       if (arena == NULL)
+               return NULL;
 
        mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, 
                                   NULL, arena);
        if (mod) {
                co = PyAST_Compile(mod, pathname, NULL, arena);
        }
-        PyArena_Free(arena);
+       PyArena_Free(arena);
        return co;
 }