[dpdk-dev,dpdk_dev] array malloced by backtrace_symbols() should be freed by the caller

Message ID 1438683666-21196-1-git-send-email-xiaobo.chi@nokia.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

chixiaobo Aug. 4, 2015, 10:21 a.m. UTC
  As to  linux man page: http://linux.die.net/man/3/backtrace_symbols, The address of the array of string pointers is returned as the function result of backtrace_symbols(). This array is malloced by backtrace_symbols(), and must be freed by the caller. The strings pointed to by the array of pointers need not and should not be freed.

Signed-off-by: chixiaobo <xiaobo.chi@nokia.com>
---
 lib/librte_eal/bsdapp/eal/eal_debug.c   | 3 +++
 lib/librte_eal/linuxapp/eal/eal_debug.c | 3 +++
 2 files changed, 6 insertions(+)
  

Patch

diff --git a/lib/librte_eal/bsdapp/eal/eal_debug.c b/lib/librte_eal/bsdapp/eal/eal_debug.c
index 44fc4f3..ceca2e8 100644
--- a/lib/librte_eal/bsdapp/eal/eal_debug.c
+++ b/lib/librte_eal/bsdapp/eal/eal_debug.c
@@ -58,6 +58,9 @@  void rte_dump_stack(void)
 			"%d: [%s]\n", size, symb[size - 1]);
 		size --;
 	}
+	/* This array is malloced by backtrace_symbols(), and must be freed by the caller */
+	if( symb )
+		free( (void *)symb );
 }
 
 /* not implemented in this environment */
diff --git a/lib/librte_eal/linuxapp/eal/eal_debug.c b/lib/librte_eal/linuxapp/eal/eal_debug.c
index 44fc4f3..ceca2e8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_debug.c
+++ b/lib/librte_eal/linuxapp/eal/eal_debug.c
@@ -58,6 +58,9 @@  void rte_dump_stack(void)
 			"%d: [%s]\n", size, symb[size - 1]);
 		size --;
 	}
+	/* This array is malloced by backtrace_symbols(), and must be freed by the caller */
+	if( symb )
+		free( (void *)symb );
 }
 
 /* not implemented in this environment */