X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fsrc%2Frtc_static.c;fp=src%2Fcommon%2Fsrc%2Frtc_static.c;h=9f0d1a68513f077b6c6849eb43c5f2a6711ec960;hb=aa0b497f216ebd8bc72850bf4af5c9f35c288b65;hp=6b9c70759e1b9b0f94429e04cf840193dbb1a033;hpb=61c5ddab38c494eabe80c19d12299094084b5ffa;p=ric-plt%2Flib%2Frmr.git diff --git a/src/common/src/rtc_static.c b/src/common/src/rtc_static.c index 6b9c707..9f0d1a6 100644 --- a/src/common/src/rtc_static.c +++ b/src/common/src/rtc_static.c @@ -92,7 +92,7 @@ static void* rtc( void* vctx ) { int state; // processing state of some nng function char* tokens[128]; char wbuf[128]; - char* pbuf; + char* pbuf = NULL; int pbuf_size = 0; // number allocated in pbuf int ntoks; int raw_interface = 1; // rtg is using raw NNG/Nano not RMr to send updates @@ -183,8 +183,12 @@ static void* rtc( void* vctx ) { if( pbuf ) { free( pbuf ); } - pbuf = (char *) malloc( sizeof( char ) * mlen *2 ); - pbuf_size = mlen * 2; + if( mlen < 512 ) { + pbuf_size = 512; + } else { + pbuf_size = mlen * 2; + } + pbuf = (char *) malloc( sizeof( char ) * pbuf_size ); } memcpy( pbuf, payload, mlen ); pbuf[mlen] = 0; // don't depend on sender making this a legit string