Skip to content

Commit

Permalink
fix memory leaks writing garmin routes. (GPSBabel#1299)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteven4 authored Jul 20, 2024
1 parent 92b4888 commit 7c83490
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion garmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 7c83490

Please sign in to comment.