libctf: fix double-free on ctf_compress_write error path
[deliverable/binutils-gdb.git] / libctf / ctf-lookup.c
index 7ea46a7295b10fc755b0fa040b7585c4180f512c..40eaf9c819dcadcb36ab4570a646c3e81836d289 100644 (file)
@@ -1,4 +1,4 @@
-/* Type lookup.
+/* Symbol, variable and name lookup.
    Copyright (C) 2019 Free Software Foundation, Inc.
 
    This file is part of libctf.
@@ -153,7 +153,7 @@ ctf_lookup_by_name (ctf_file_t *fp, const char *name)
              else
                {
                  free (fp->ctf_tmp_typeslice);
-                 fp->ctf_tmp_typeslice = strndup (p, (size_t) (q - p));
+                 fp->ctf_tmp_typeslice = xstrndup (p, (size_t) (q - p));
                  if (fp->ctf_tmp_typeslice == NULL)
                    {
                      (void) ctf_set_errno (fp, ENOMEM);
@@ -412,8 +412,8 @@ ctf_func_args (ctf_file_t * fp, unsigned long symidx, uint32_t argc,
   const uint32_t *dp;
   ctf_funcinfo_t f;
 
-  if (ctf_func_info (fp, symidx, &f) == CTF_ERR)
-    return CTF_ERR;            /* errno is set for us.  */
+  if (ctf_func_info (fp, symidx, &f) < 0)
+    return -1;                 /* errno is set for us.  */
 
   /* The argument data is two uint32_t's past the translation table
      offset: one for the function info, and one for the return type. */
This page took 0.024793 seconds and 4 git commands to generate.