X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fcommon%2Fsrc%2Fwrapper.c;h=55cfe9e15b1f191f29592b7a83b834d4bbe42b7f;hb=d961525e9eb23e3dee4a16960a1772782c3b8b36;hp=18d2a239962250fc2f332fa9458be1207c0973c2;hpb=4441a79be9a6f9d1b4ec0111eb0030a8f2e3e5e5;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/common/src/wrapper.c b/src/rmr/common/src/wrapper.c index 18d2a23..55cfe9e 100644 --- a/src/rmr/common/src/wrapper.c +++ b/src/rmr/common/src/wrapper.c @@ -63,8 +63,9 @@ static char* build_sval( char* name, char* val, int add_sep ) { strcat src is freed as a convenience. Max is the max amount that target can accept; we don't bang on if src len is larger than max. Return is the size of src; 0 if the - target was not modified. If target is not modified, then - src is NOT released. + target was not modified. + + Source is ALWAYS freed! */ static int bang_on( char* target, char* src, int max ) { int len; @@ -74,10 +75,12 @@ static int bang_on( char* target, char* src, int max ) { len = strlen( src ); if( (rc = len <= max ? len : 0 ) > 0 ) { // if it fits, add it. strcat( target, src ); - free( src ); } } + if( src ) { + free( src ); + } return rc; }