From: Arnaud Giersch Date: Tue, 28 Jun 2022 11:46:33 +0000 (+0200) Subject: Avoid memory leak when exception is thrown. X-Git-Tag: v3.32~181 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/506ba578d0a050e4e5ca2102d0ffa1414108d5c9 Avoid memory leak when exception is thrown. --- diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index 908f57e131..e7c2c79956 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -27,11 +27,10 @@ RoutedZone::RoutedZone(const std::string& name) : NetZoneImpl(name) {} Route* RoutedZone::new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst, const std::vector& link_list, bool preserve_order) { - auto* result = new Route(); + xbt_enforce(hierarchy != RoutingMode::recursive || (gw_src && gw_dst), "nullptr is obviously a deficient gateway"); + auto* result = new Route(); if (hierarchy == RoutingMode::recursive) { - xbt_enforce(gw_src && gw_dst, "nullptr is obviously a deficient gateway"); - result->gw_src_ = gw_src; result->gw_dst_ = gw_dst; }