@@ -114,11 +114,11 @@ void processIssueTypeEvent(data_buf *rbuf)
114114 }
115115
116116 }
117- if ( cmdMap )
118- {
117+ if ( cmdMap )
118+ {
119119 free (cmdMap );
120- cmdMap = NULL ;
121- }
120+ cmdMap = NULL ;
121+ }
122122 }
123123 }
124124
@@ -164,6 +164,16 @@ static void processIssueType(data_buf *rbuf)
164164 if (staticprofiledata == NULL )
165165 {
166166 RDK_LOG (RDK_LOG_INFO , LOG_REMDEBUG , "[%s:%d]: Static Command Info not found for IssueType!!! \n" , __FUNCTION__ , __LINE__ );
167+ // Free dynamicprofiledata since we can't proceed
168+ if (dynamicprofiledata -> rfcvalue != NULL )
169+ {
170+ free (dynamicprofiledata -> rfcvalue );
171+ }
172+ if (dynamicprofiledata -> command != NULL )
173+ {
174+ free (dynamicprofiledata -> command );
175+ }
176+ free (dynamicprofiledata );
167177 }
168178 else
169179 {
@@ -173,22 +183,60 @@ static void processIssueType(data_buf *rbuf)
173183 size_t dynamicstrlen = strlen (dynamicprofiledata -> command );
174184 if (staticstrlen > 0 && staticprofiledata -> command [staticstrlen - 1 ] == '"' ) {
175185 staticprofiledata -> command [staticstrlen - 1 ] = '\0' ;
186+ staticstrlen -- ; // Update length after removing trailing quote
176187 }
177188 if (dynamicprofiledata -> command [0 ] == '"' ) {
178189 dynamicprofiledata -> command [0 ] = COMMAND_DELIM ;
179190 }
180191 RDK_LOG (RDK_LOG_DEBUG , LOG_REMDEBUG , "[%s:%d]: Static Profile Commands: %s, Dynamic Profile Commands: %s\n" , __FUNCTION__ , __LINE__ , staticprofiledata -> command , dynamicprofiledata -> command );
181192
182- size_t appendstrlen = (( staticstrlen - 1 ) + dynamicstrlen + 1 );
193+ size_t appendstrlen = (staticstrlen + dynamicstrlen + 1 );
183194 char * appendcommandstr = (char * )realloc (staticprofiledata -> command , appendstrlen );
184195 if (appendcommandstr == NULL ) {
185- RDK_LOG (RDK_LOG_DEBUG , LOG_REMDEBUG , "[%s:%d]: Memory Allocation Failed... \n" , __FUNCTION__ , __LINE__ );
196+ RDK_LOG (RDK_LOG_ERROR , LOG_REMDEBUG , "[%s:%d]: Memory Allocation Failed... \n" , __FUNCTION__ , __LINE__ );
197+ // Free staticprofiledata on realloc failure
198+ if (staticprofiledata -> rfcvalue != NULL )
199+ {
200+ free (staticprofiledata -> rfcvalue );
201+ }
202+ if (staticprofiledata -> command != NULL )
203+ {
204+ free (staticprofiledata -> command );
205+ }
206+ free (staticprofiledata );
207+ // Free dynamicprofiledata on realloc failure
208+ if (dynamicprofiledata -> rfcvalue != NULL )
209+ {
210+ free (dynamicprofiledata -> rfcvalue );
211+ }
212+ if (dynamicprofiledata -> command != NULL )
213+ {
214+ free (dynamicprofiledata -> command );
215+ }
216+ free (dynamicprofiledata );
217+ dynamicprofiledata = NULL ; // Set to NULL to prevent double-free
218+ }
219+ else
220+ {
221+ strcat (appendcommandstr , dynamicprofiledata -> command );
222+ staticprofiledata -> command = appendcommandstr ;
223+ RDK_LOG (RDK_LOG_INFO , LOG_REMDEBUG , "[%s:%d]: Updated command after append from dynamic and static profile: %s \n" , __FUNCTION__ , __LINE__ , staticprofiledata -> command );
224+ RDK_LOG (RDK_LOG_DEBUG ,LOG_REMDEBUG ,"[%s:%d]: Executing Commands in Runtime Service... \n" ,__FUNCTION__ ,__LINE__ );
225+ checkIssueNodeInfo (pIssueNode , NULL , rbuf , false, staticprofiledata );
226+ }
227+ // Free dynamicprofiledata after use (only if not already freed)
228+ if (dynamicprofiledata != NULL )
229+ {
230+ if (dynamicprofiledata -> rfcvalue != NULL )
231+ {
232+ free (dynamicprofiledata -> rfcvalue );
233+ }
234+ if (dynamicprofiledata -> command != NULL )
235+ {
236+ free (dynamicprofiledata -> command );
237+ }
238+ free (dynamicprofiledata );
186239 }
187- strcat (appendcommandstr , dynamicprofiledata -> command );
188- staticprofiledata -> command = appendcommandstr ;
189- RDK_LOG (RDK_LOG_INFO , LOG_REMDEBUG , "[%s:%d]: Updated command after append from dynamic and static profile: %s \n" , __FUNCTION__ , __LINE__ , staticprofiledata -> command );
190- RDK_LOG (RDK_LOG_DEBUG ,LOG_REMDEBUG ,"[%s:%d]: Executing Commands in Runtime Service... \n" ,__FUNCTION__ ,__LINE__ );
191- checkIssueNodeInfo (pIssueNode , NULL , rbuf , false, staticprofiledata );
192240 }
193241 }
194242 }
@@ -303,6 +351,8 @@ static void processIssueTypeInStaticProfile(data_buf *rbuf, issueNodeData *pIssu
303351 { // Static Profile JSON Parsing or Read Fail
304352 RDK_LOG (RDK_LOG_ERROR , LOG_REMDEBUG , "[%s:%d]: Static Profile Parse/Read failed... %s\n" , __FUNCTION__ , __LINE__ , RRD_JSON_FILE );
305353 processIssueTypeInInstalledPackage (rbuf , pIssueNode );
354+ RDK_LOG (RDK_LOG_DEBUG , LOG_REMDEBUG , "[%s:%d]: ...Exiting...\n" , __FUNCTION__ , __LINE__ );
355+ return ;
306356 }
307357 RDK_LOG (RDK_LOG_DEBUG , LOG_REMDEBUG , "[%s:%d]: Static Profile Parse And Read Success... %s\n" , __FUNCTION__ , __LINE__ , RRD_JSON_FILE );
308358 RDK_LOG (RDK_LOG_DEBUG , LOG_REMDEBUG , "[%s:%d]: Check if Issue in Parsed Static JSON... %s\n" , __FUNCTION__ , __LINE__ , RRD_JSON_FILE );
0 commit comments