abg-tools-utils: Fix memory leak when using CTF option

Message ID 20240830121220.865234-1-claudiu.zissulescu-ianculescu@oracle.com
State New
Headers
Series abg-tools-utils: Fix memory leak when using CTF option |

Commit Message

Claudiu Zissulescu-Ianculescu Aug. 30, 2024, 12:12 p.m. UTC
  From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

The scope of di_root_ctf_ptr is limited to if-block, leading to
dropping the CTF reader when using abipkgdiff tool. Fix it.

	* src/abg-tools-utils.cc
	(build_corpus_group_from_kernel_dist_under): change the scope of
	di_root_ctf_ptr variable.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
---
 src/abg-tools-utils.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Dodji Seketeli Aug. 30, 2024, 3:42 p.m. UTC | #1
Hello,

claudiu.zissulescu-ianculescu@oracle.com a écrit:

> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> The scope of di_root_ctf_ptr is limited to if-block, leading to
> dropping the CTF reader when using abipkgdiff tool. Fix it.
>
> 	* src/abg-tools-utils.cc
> 	(build_corpus_group_from_kernel_dist_under): change the scope of
> 	di_root_ctf_ptr variable.
>
> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

Applied to master, thanks!

Cheers,
  

Patch

diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc
index 1bc2e233..bfc33d70 100644
--- a/src/abg-tools-utils.cc
+++ b/src/abg-tools-utils.cc
@@ -3155,10 +3155,11 @@  build_corpus_group_from_kernel_dist_under(const string&	root,
 
 #ifdef WITH_CTF
       shared_ptr<char> di_root_ctf;
+      char *di_root_ctf_ptr;
       if (requested_fe_kind & corpus::CTF_ORIGIN)
         {
           di_root_ctf = make_path_absolute(root.c_str());
-          char *di_root_ctf_ptr = di_root_ctf.get();
+          di_root_ctf_ptr = di_root_ctf.get();
           di_roots.push_back(&di_root_ctf_ptr);
         }
 #endif