libctf: allow ctf_type_lname of a null pointer.
The code was meant to handle this, but accidentally dereferenced the null pointer before checking it for nullity. v5: fix tabdamage. libctf/ * ctf-types.c (ctf_type_name): Don't strlen a potentially- null pointer.
This commit is contained in:
parent
99dc3ebdff
commit
1a6ab13e71
2 changed files with 7 additions and 1 deletions
|
@ -438,11 +438,12 @@ ssize_t
|
|||
ctf_type_lname (ctf_file_t *fp, ctf_id_t type, char *buf, size_t len)
|
||||
{
|
||||
char *str = ctf_type_aname (fp, type);
|
||||
size_t slen = strlen (str);
|
||||
size_t slen;
|
||||
|
||||
if (str == NULL)
|
||||
return CTF_ERR; /* errno is set for us */
|
||||
|
||||
slen = strlen (str);
|
||||
snprintf (buf, len, "%s", str);
|
||||
free (str);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue