[06/11] libctf: fix dict leak on archive-wide symbol lookup error path

Message ID 20240613185430.85352-7-nick.alcock@oracle.com
State New
Headers
Series enumerator query API, plus some bugfixes |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Nick Alcock June 13, 2024, 6:54 p.m. UTC
  If a lookup fails for a reason unrelated to a lack of type data for this
symbol, we return with an error; but we fail to close the dict we opened
most recently, which is leaked.

libctf/
	* ctf-archive.c (ctf_arc_lookup_sym_or_name): Close dict.
---
 libctf/ctf-archive.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/libctf/ctf-archive.c b/libctf/ctf-archive.c
index f459c02e702..4744cb7a828 100644
--- a/libctf/ctf-archive.c
+++ b/libctf/ctf-archive.c
@@ -957,6 +957,7 @@  ctf_arc_lookup_sym_or_name (ctf_archive_t *wrapper, unsigned long symidx,
 	{
 	  if (errp)
 	    *errp = ctf_errno (fp);
+	  ctf_dict_close (fp);
 	  ctf_next_destroy (i);
 	  return NULL;				/* errno is set for us.  */
 	}