diff --git a/vpr/src/route/route_timing.cpp b/vpr/src/route/route_timing.cpp index b2ebaa43791..4d8c0e12cab 100644 --- a/vpr/src/route/route_timing.cpp +++ b/vpr/src/route/route_timing.cpp @@ -893,9 +893,14 @@ void alloc_timing_driven_route_structs(float** pin_criticality_ptr, int max_sinks = std::max(get_max_pins_per_net() - 1, 0); - *pin_criticality_ptr = new float[max_sinks] - 1; /* First sink is pin #1. */ - *sink_order_ptr = new int[max_sinks] - 1; - *rt_node_of_sink_ptr = new t_rt_node*[max_sinks] - 1; + *pin_criticality_ptr = new float[max_sinks + 1]; /* First sink is pin #1.*/ + *sink_order_ptr = new int[max_sinks + 1]; + *rt_node_of_sink_ptr = new t_rt_node*[max_sinks + 1]; + + /* Element 0 should be an invalid value so we are likely to crash if we accidentally use it. */ + (*pin_criticality_ptr)[0] = -1; + (*sink_order_ptr)[0] = -1; + (*rt_node_of_sink_ptr)[0] = nullptr; alloc_route_tree_timing_structs(); } @@ -908,11 +913,11 @@ void free_timing_driven_route_structs(float* pin_criticality, int* sink_order, t /* Frees all the structures needed only by the timing-driven router. */ // coverity[offset_free : Intentional] - delete[](pin_criticality + 1); /* Starts at index 1. */ + delete[](pin_criticality); // coverity[offset_free : Intentional] - delete[](sink_order + 1); + delete[](sink_order); // coverity[offset_free : Intentional] - delete[](rt_node_of_sink + 1); + delete[](rt_node_of_sink); free_route_tree_timing_structs(); }