summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c7
-rw-r--r--Python/marshal.c5
-rw-r--r--Python/pystrtod.c7
3 files changed, 14 insertions, 5 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 51175cd..675063e 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);
diff --git a/Python/marshal.c b/Python/marshal.c
index 91a57c2..dbe75e3 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -677,11 +677,12 @@ r_string(Py_ssize_t n, RFILE *p)
p->buf_size = n;
}
else if (p->buf_size < n) {
- p->buf = PyMem_REALLOC(p->buf, n);
- if (p->buf == NULL) {
+ char *tmp = PyMem_REALLOC(p->buf, n);
+ if (tmp == NULL) {
PyErr_NoMemory();
return NULL;
}
+ p->buf = tmp;
p->buf_size = n;
}
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 1c63560..509048c 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -398,6 +398,9 @@ _Py_string_to_number_with_underscores(
}
dup = PyMem_Malloc(orig_len + 1);
+ if (dup == NULL) {
+ return PyErr_NoMemory();
+ }
end = dup;
prev = '\0';
last = s + orig_len;
@@ -433,8 +436,8 @@ _Py_string_to_number_with_underscores(
error:
PyMem_Free(dup);
PyErr_Format(PyExc_ValueError,
- "could not convert string to %s: "
- "%R", what, obj);
+ "could not convert string to %s: "
+ "%R", what, obj);
return NULL;
}