@@ -173,20 +173,22 @@ void convert_print_list_to_lines()
173173 temp_buf = (char *) malloc (strlen (string_from_list) + 1 );
174174 rtapi_strlcpy (temp_buf, string_from_list, strlen (string_from_list) + 1 );
175175 } else {
176- temp_buf = (char *) realloc (temp_buf, strlen (temp_buf)
177- + strlen (string_from_list) + 1 );
178- strcat (temp_buf, string_from_list);
176+ char *ra = (char *) realloc (temp_buf, strlen (temp_buf) + strlen (string_from_list) + 1 );
177+ if (ra) {
178+ temp_buf = ra;
179+ strcat (temp_buf, string_from_list);
180+ }
179181 }
180182 rcs_print_list->delete_current_node ();
181183 } else {
182184 if (temp_buf != NULL ) {
183- temp_buf = (char *) realloc (temp_buf, strlen (temp_buf)
184- + strlen (string_from_list) + 1 );
185- strcat ( temp_buf, string_from_list) ;
186- rcs_print_list-> delete_current_node ( );
187- rcs_print_list->store_after_current_node (temp_buf,
188- strlen (temp_buf)
189- + 1 , 1 );
185+ char *ra = (char *) realloc (temp_buf, strlen (temp_buf) + strlen (string_from_list) + 1 );
186+ if (ra) {
187+ temp_buf = ra ;
188+ strcat (temp_buf, string_from_list );
189+ rcs_print_list->delete_current_node ();
190+ rcs_print_list-> store_after_current_node (temp_buf, strlen (temp_buf) + 1 , 1 );
191+ }
190192 free (temp_buf);
191193 temp_buf = NULL ;
192194 } else if (next_line[1 ] != 0 ) {
@@ -214,9 +216,8 @@ void update_lines_table()
214216 }
215217 if (NULL != rcs_print_list) {
216218 convert_print_list_to_lines ();
217- rcs_lines_table = (char **) malloc (sizeof (char *)
218- * rcs_print_list->list_size );
219- if (NULL != rcs_print_list) {
219+ rcs_lines_table = (char **) malloc (sizeof (char *) * rcs_print_list->list_size );
220+ if (NULL != rcs_lines_table) {
220221 char *string_from_list;
221222 string_from_list = (char *) rcs_print_list->get_head ();
222223 int i = 0 ;
0 commit comments