From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Sat, 20 Jul 2024 12:48:06 +0000 (-0600) Subject: fix memory leaks writing garmin routes. (#1299) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2^2~88 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7c834907b18980b4a279741522e7ecc4a70434dd;p=gpsbabel.git fix memory leaks writing garmin routes. (#1299) --- diff --git a/garmin.cc b/garmin.cc index cea5e6c4d..29036fd3e 100644 --- a/garmin.cc +++ b/garmin.cc @@ -981,7 +981,7 @@ GarminFormat::route_waypt_pr(const Waypoint* wpt) void GarminFormat::route_write() { - int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ + const int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */ tx_routelist = (GPS_SWay**) xcalloc(n,sizeof(GPS_PWay)); cur_tx_routelist_entry = tx_routelist; @@ -998,6 +998,12 @@ GarminFormat::route_write() }; route_disp_all(route_hdr_pr_lambda, nullptr, route_waypt_pr_lambda); GPS_Command_Send_Route(portname, tx_routelist, n); + + for (int i = 0; i < n; i++) { + GPS_Way_Del(&tx_routelist[i]); + } + + xfree(tx_routelist); } void