summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
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 24d5843..8a305a8 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -4097,6 +4097,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 != '_') {
@@ -4325,8 +4328,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);