@@ -2146,8 +2146,7 @@ void merge_lines_to_draw(struct lines_to_draw *lines_master,struct lines_to_draw
21462146 if (lines_master -> number_of_lines == 0 ) {
21472147 lines_master -> number_of_lines = lines_new -> number_of_lines ;
21482148 if (!lines_master -> number_of_lines ) {
2149- fprintf (stderr ,"Failure allocating list in Union function merge_lines_to_draw 1 - Exit!\n" );
2150- exit (EXIT_FAILURE );
2149+ return ;
21512150 }
21522151 lines_master -> lines = malloc (lines_master -> number_of_lines * sizeof (struct line_segment ));
21532152 if (!lines_master -> lines ) {
@@ -2308,23 +2307,27 @@ struct lines_to_draw draw_line_with_highest_priority(Coords position1,Coords pos
23082307 int geometry_output ;
23092308
23102309 // Todo: switch to nicer intersect function call
2311- double * double_dummy = malloc (2 * sizeof (double ));
2312- int int_dummy [ 2 ] ;
2310+ double * double_dummy = malloc (max_number_of_solutions * sizeof (double ));
2311+ int * int_dummy = malloc ( max_number_of_solutions * sizeof ( int )) ;
23132312 // We need a storing pointer for the reallocs, to ensure that on realloc fail
23142313 // All is handled correctly
23152314 double * tmp ;
2315+ int * tmpint ;
23162316
23172317 // Find intersections
23182318 for (volume_index = 1 ;volume_index < number_of_volumes ; volume_index ++ ) {
23192319 if (volume_index != N ) {
23202320 if (Geometries [volume_index ]-> eShape == mesh ){
23212321 tmp = realloc (double_dummy , sizeof (double )* 1000 );
2322- if ( tmp == NULL ) {
2322+ tmpint = realloc (int_dummy , sizeof (double )* 1000 );
2323+ if ( tmp == NULL || tmpint == NULL ) {
23232324 free (tmp );
2325+ free (tmpint );
23242326 printf ("\nERROR: Realloc failed on double dummy" );
23252327 exit (1 );
23262328 } else {
23272329 double_dummy = tmp ;
2330+ int_dummy = tmpint ;
23282331 tmp = realloc (temp_intersection , sizeof (double )* 1000 );
23292332 if ( tmp == NULL ){
23302333 free (tmp );
0 commit comments