mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015)
Set MemoryError when appropriate, add missing failure checks, and fix some potential leaks.
This commit is contained in:
parent
3a521f0b61
commit
4c49da0cb7
17 changed files with 113 additions and 27 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue