Ack Thanks Lennart
> -----Original Message----- > From: Canh Van Truong [mailto:canh.v.tru...@dektech.com.au] > Sent: den 13 mars 2017 13:19 > To: Lennart Lund <lennart.l...@ericsson.com>; Vu Minh Nguyen > <vu.m.ngu...@dektech.com.au>; mahesh.va...@oracle.com > Cc: opensaf-devel@lists.sourceforge.net > Subject: [PATCH 1 of 1] log: fix logd crash on Active side [#2362] > > src/log/logd/lgs_filehdl.cc | 21 +++++++++++++-------- > 1 files changed, 13 insertions(+), 8 deletions(-) > > > The cause of issue is free cfg_namelist while struct dirent **cfg_namelist > unallocated > > diff --git a/src/log/logd/lgs_filehdl.cc b/src/log/logd/lgs_filehdl.cc > --- a/src/log/logd/lgs_filehdl.cc > +++ b/src/log/logd/lgs_filehdl.cc > @@ -1,6 +1,7 @@ > /* -*- OpenSAF -*- > * > * (C) Copyright 2013 The OpenSAF Foundation > + * Copyright Ericsson AB 2013, 2017 - All Rights Reserved. > * > * This program is distributed in the hope that it will be useful, but > * WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY > @@ -704,8 +705,8 @@ done_exit: > * @return int, number of cfgfiles or -1 if error > */ > int get_number_of_cfg_files_hdl(void *indata, void *outdata, size_t > max_outsize) { > - struct dirent **cfg_namelist; > - struct dirent **log_namelist; > + struct dirent **cfg_namelist = nullptr; > + struct dirent **log_namelist = nullptr; > int n, cfg_old_date = -1, cfg_old_time = -1, old_ind = -1, cfg_files = 0, > i, > failed = 0; > int log_old_date = -1, log_old_time = -1 , log_files = 0; > std::string path; > @@ -802,15 +803,19 @@ int get_number_of_cfg_files_hdl(void *in > > done_cfg_free: > /* Free scandir allocated memory */ > - for (i = 0; i < cfg_files; i++) > - free(cfg_namelist[i]); > - free(cfg_namelist); > + if (cfg_namelist != NULL) { > + for (i = 0; i < cfg_files; i++) > + free(cfg_namelist[i]); > + free(cfg_namelist); > + } > > done_log_free: > /* Free scandir allocated memory */ > - for (i = 0; i < log_files; i++) > - free(log_namelist[i]); > - free(log_namelist); > + if (log_namelist != NULL) { > + for (i = 0; i < log_files; i++) > + free(log_namelist[i]); > + free(log_namelist); > + } > > done_exit: > TRACE_LEAVE(); ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel