X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcommon%2Fsrc%2Frtc_static.c;h=9f0d1a68513f077b6c6849eb43c5f2a6711ec960;hb=refs%2Fchanges%2F47%2F47%2F2;hp=6b9c70759e1b9b0f94429e04cf840193dbb1a033;hpb=fd9cc7a5b3355146388ebdf4d558cb284c66c5f1;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