Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[2.7] bpo-34457: Python/ast.c: Add missing NULL check to alias_for_im…
…port_name(). (GH-8852)

Reported by Svace static analyzer..
(cherry picked from commit 28853a2)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
  • Loading branch information
Alexey Izbyshev
Alexey Izbyshev committed Aug 22, 2018
commit 3b11234ec7eb3c6c881aa6365a85695d0ece7b49
2 changes: 2 additions & 0 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2520,6 +2520,8 @@ alias_for_import_name(struct compiling *c, const node *n, int store)
break;
case STAR:
str = PyString_InternFromString("*");
if (!str)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case the if sentence could fail?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an unlikely case of one-character-string cache miss combined with memory allocation failure.

return NULL;
PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
default:
Expand Down