summaryrefslogtreecommitdiff
path: root/Python/ast.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-12-07 18:09:23 +0200
committerGitHub <noreply@github.com>2018-12-07 18:09:23 +0200
commit2d6bc25dbc3dc5662f13917eb759f92842bf6de6 (patch)
treed1dde41b6c7e9c5dafa95703bd4f0a4ab6b2bfb7 /Python/ast.c
parent19f6e83bf03b3ce22300638906bd90dd2dd5c463 (diff)
downloadcpython-git-2d6bc25dbc3dc5662f13917eb759f92842bf6de6.tar.gz
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) (GH-11020) (GH-11026)
(cherry picked from commit 4c49da0cb7434c676d70b9ccf38aca82ac0d64a9) (cherry picked from commit 602d307ac5e8a2da38a193dca3bdfef5994dfe67) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 51175cdb55..675063eff0 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -4104,6 +4104,9 @@ parsenumber(struct compiling *c, const char *s)
}
/* Create a duplicate without underscores. */
dup = PyMem_Malloc(strlen(s) + 1);
+ if (dup == NULL) {
+ return PyErr_NoMemory();
+ }
end = dup;
for (; *s; s++) {
if (*s != '_') {
@@ -4338,8 +4341,10 @@ fstring_compile_expr(const char *expr_start, const char *expr_end,
len = expr_end - expr_start;
/* Allocate 3 extra bytes: open paren, close paren, null byte. */
str = PyMem_RawMalloc(len + 3);
- if (str == NULL)
+ if (str == NULL) {
+ PyErr_NoMemory();
return NULL;
+ }
str[0] = '(';
memcpy(str+1, expr_start, len);