[2/3] libctf: fix use-after-free in function dumping

Message ID 20190603204735.203510-2-nick.alcock@oracle.com
State New
Headers show
Series
  • [1/3] libctf: fix the type of ctf_enum.cte_value
Related show

Commit Message

Nick Alcock June 3, 2019, 8:47 p.m.
This is actually a free-before-initializing (i.e. a free of garbage).

libctf/
	* ctf-dump.c (ctf_dump_funcs): Free in the right place.
---
 libctf/ctf-dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.21.0.237.gd0cfaa883d

Patch

diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index c2ed791eea..82f63c29d0 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -273,7 +273,6 @@  ctf_dump_funcs (ctf_file_t *fp, ctf_dump_state_t *state)
 	goto err;
 
       str = ctf_str_append (str, " ");
-      free (bit);
 
       /* Function name.  */
 
@@ -290,6 +289,7 @@  ctf_dump_funcs (ctf_file_t *fp, ctf_dump_state_t *state)
 	}
       str = ctf_str_append (str, bit);
       str = ctf_str_append (str, " (");
+      free (bit);
 
       /* Function arguments.  */