mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Handle malloc failure.
Klocwork 281
This commit is contained in:
parent
ccc56c7c96
commit
9ac8953568
1 changed files with 4 additions and 0 deletions
|
|
@ -199,6 +199,10 @@ translabel(grammar *g, label *lb)
|
|||
else
|
||||
name_len = strlen(src);
|
||||
dest = (char *)malloc(name_len + 1);
|
||||
if (!dest) {
|
||||
printf("Can't alloc dest '%s'\n", src);
|
||||
return;
|
||||
}
|
||||
strncpy(dest, src, name_len);
|
||||
dest[name_len] = '\0';
|
||||
free(lb->lb_str);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue