Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-11 Thread Hans Nordebäck
ack, review only. /Thanks HansN On 04/05/2018 04:39 AM, Vu Minh Nguyen wrote: The allocated memory is not freed before returning from the function ImmModel::setCcbErrorString(). --- src/imm/immnd/ImmModel.cc | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-04 Thread Vu Minh Nguyen
Hi Hans, Now, I got your idea of using RAII for ` fmtError`. Thanks for your comment.  See my responses inline for your comment regarding variable arguments. Regards, Vu > -Original Message- > From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] > Sent: Wednesday, April 4, 2018

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-04 Thread Hans Nordebäck
Hi Zoran, yes you are right, hm, I didn't check the whole function... /BR Hans On 04/04/2018 09:57 AM, Zoran Milinkovic wrote: Hi Hans, Variable arguments with vsnprintf will work. The size of the new buffer is resized in if (len > errLen) { ... osafassert(vsnprintf(fmtError, len,

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-04 Thread Zoran Milinkovic
Hi Hans, Variable arguments with vsnprintf will work. The size of the new buffer is resized in if (len > errLen) { ... osafassert(vsnprintf(fmtError, len, errorString, vl) >= 0); } when there are variable arguments. BR, Zoran -Original Message- From: Hans Nordebäck Sent: den 4

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-04 Thread Hans Nordebäck
Hi Vu, not saying that you should change now, but an alternative can be to: instead of: char* fmtError = (char*) malloc(errLen);   osafassert(fmtError); a std::vector can be used, (or a std::array if fixed size): std::vector fmtError(errLen, 0);    : len = vsnprintf(fmtError.data(),

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-03 Thread Vu Minh Nguyen
Hi Hans, Anders, Please see my responses inline, with [Vu]. P.s: Please ignore previous email. I pressed wrong keys... Regards, Vu > -Original Message- > From: Anders Widell [mailto:anders.wid...@ericsson.com] > Sent: Tuesday, April 3, 2018 7:07 PM > To: Hans Nordebäck

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-03 Thread Vu Minh Nguyen
Hi Hans, Anders, Please see my responses inline, with [Vu]. Regards, Vu > -Original Message- > From: Anders Widell [mailto:anders.wid...@ericsson.com] > Sent: Tuesday, April 3, 2018 7:07 PM > To: Hans Nordebäck ; Vu Minh Nguyen >

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-03 Thread Anders Widell
Ack with comments. There is actually a second memory leak further down in this function:     char* newFmtError = (char*)realloc(fmtError, len);     if (newFmtError == nullptr) {   TRACE_5("realloc error ,No memory ");   return;     } else { When realloc returns nullptr, the original

Re: [devel] [PATCH 1/1] imm: fix memory leaked in immnd [#2825]

2018-04-03 Thread Hans Nordebäck
Hi Vu, few minor comments below. /Thanks HansN On 04/03/2018 11:43 AM, Vu Minh Nguyen wrote: The allocated memory is not freed before returning from the function ImmModel::setCcbErrorString(). --- src/imm/immnd/ImmModel.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff