libctf: allow ctf_type_lname of a null pointer.
authorNick Alcock <nick.alcock@oracle.com>
Thu, 8 Aug 2019 15:53:48 +0000 (16:53 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Thu, 3 Oct 2019 16:04:56 +0000 (17:04 +0100)
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.

libctf/ChangeLog
libctf/ctf-types.c

index 106955385dbeb947845db0ec06382999db40fda0..8f41ece32b071c16627b02f12fb7e63d46ba1fdc 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-08  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-types.c (ctf_type_name): Don't strlen a potentially-
+       null pointer.
+
 2019-08-07  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-impl.h (ctf_file_t) <ctf_add_processing>: New.
index 6e6776223438c5c3ee99260274317d1e6183b58e..ec221d734948e12faac78af46abd71c68dfb167e 100644 (file)
@@ -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);
 
This page took 0.025065 seconds and 4 git commands to generate.