Hi Thuan, Thanks for your comment. See my respond inline.
-----Original Message----- From: Thuan Tran <thuan.t...@dektech.com.au> Sent: Tuesday, June 9, 2020 8:40 PM To: Thang Duc Nguyen <thang.d.ngu...@dektech.com.au>; Vu Minh Nguyen <vu.m.ngu...@dektech.com.au>; Thien Minh Huynh <thien.m.hu...@dektech.com.au>; Minh Hon Chau <minh.c...@dektech.com.au> Cc: opensaf-devel@lists.sourceforge.net Subject: RE: [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Hi Thang, Some comments inline. One concern, LOG ticket but change src/base/daemon.c Is it acceptable? Or need create different ticket? [Thang]: It just modify a little so I don't want to create a new one. Let wait Minh's idea. Best Regards, ThuanTr -----Original Message----- From: Thang Duc Nguyen <thang.d.ngu...@dektech.com.au> Sent: Tuesday, June 2, 2020 5:53 PM To: Vu Minh Nguyen <vu.m.ngu...@dektech.com.au>; Thien Minh Huynh <thien.m.hu...@dektech.com.au>; Thuan Tran <thuan.t...@dektech.com.au>; Minh Hon Chau <minh.c...@dektech.com.au> Cc: opensaf-devel@lists.sourceforge.net; Thang Duc Nguyen <thang.d.ngu...@dektech.com.au> Subject: [PATCH 1/1] lgs: fix memory leak reeported by valgrind [#3195] Fix definitely lost reported by valgrind. --- src/base/daemon.c | 6 ++++-- src/log/logd/lgs_imm.cc | 8 ++++++++ src/log/logd/lgs_mbcsv.cc | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/base/daemon.c b/src/base/daemon.c index 48a0665f2..2b23b43c3 100644 --- a/src/base/daemon.c +++ b/src/base/daemon.c @@ -57,7 +57,7 @@ #define DEFAULT_RUNAS_USERNAME "opensaf" -static const char *internal_version_id_; +static char internal_version_id_[53]; static char fifo_file[NAME_MAX]; static char __pidfile[NAME_MAX]; @@ -294,7 +294,9 @@ void daemonize(int argc, char *argv[]) char buf1[256 + sizeof("_SCHED_PRIORITY")] = {0}; char buf2[256 + sizeof("_SCHED_POLICY")] = {0}; - internal_version_id_ = strdup("@(#) $Id: " INTERNAL_VERSION_ID " $"); + strcpy(internal_version_id_, "@(#) $Id: "); + strcat(internal_version_id_, INTERNAL_VERSION_ID); + strcat(internal_version_id_, " $"); [Thuan] Can we use one line of code by snprintf(...)? [Thang]: OK. Will update in V3. if (argc > 0 && argv != NULL) { __parse_options(argc, argv); diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc index 9094be5f3..1889a57b3 100644 --- a/src/log/logd/lgs_imm.cc +++ b/src/log/logd/lgs_imm.cc @@ -3027,6 +3027,14 @@ SaAisErrorT lgs_imm_init_configStreams(lgs_cb_t *cb) { } done: + /* Free memory allocated for attribute descriptions */ om_rc = + saImmOmClassDescriptionMemoryFree_2(omHandle, attr_definitions); if + (om_rc != SA_AIS_OK) { + LOG_NO("saImmOmClassDescriptionMemoryFree_2() Fail %s", + saf_error(om_rc)); + goto done; [Thuan] Remove "goto done;" [Thang]: OK. Will update in V3. + } + /* Do not abort if error when finalizing */ om_rc = immutil_saImmOmSearchFinalize(immSearchHandle); if (om_rc != SA_AIS_OK) { diff --git a/src/log/logd/lgs_mbcsv.cc b/src/log/logd/lgs_mbcsv.cc index 6ec004f0a..2d1271c1c 100644 --- a/src/log/logd/lgs_mbcsv.cc +++ b/src/log/logd/lgs_mbcsv.cc @@ -2502,6 +2502,7 @@ done: lgs_free_edu_mem(param->fileFmt); lgs_free_edu_mem(param->logFileCurrent); lgs_free_edu_mem(param->logStreamName); + lgs_free_edu_mem(param->dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; @@ -2813,6 +2814,7 @@ done: lgs_free_edu_mem(logFileFormat); lgs_free_edu_mem(logFileCurrent); lgs_free_edu_mem(name); + lgs_free_edu_mem(dest_names); TRACE_LEAVE(); return NCSCC_RC_SUCCESS; -- 2.17.1 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel