qmapshack/qmapshack-1.15.0-fix_crash_in_profile.patch

41 lines
1.8 KiB
Diff

From 277626d9d3482fe0c64ad66a30c8d7dc7416f81b Mon Sep 17 00:00:00 2001
From: John Floyd <jfloyd@bigpond.net.au>
Date: Wed, 24 Jun 2020 13:39:31 +1000
Subject: [PATCH] [QMS-217] Fix Crash in Profile
Routino_GetProfiles returns a NULL result if profile is not in profiles.
Catch this error and display error message.
This coding error predates latest profiles work.
---
changelog.txt | 1 +
src/qmapshack/gis/rte/router/CRouterRoutino.cpp | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/src/qmapshack/gis/rte/router/CRouterRoutino.cpp b/src/qmapshack/gis/rte/router/CRouterRoutino.cpp
index 91ba62c3..cc32674c 100644
--- a/src/qmapshack/gis/rte/router/CRouterRoutino.cpp
+++ b/src/qmapshack/gis/rte/router/CRouterRoutino.cpp
@@ -378,6 +378,10 @@ void CRouterRoutino::calcRoute(const IGisItem::key_t& key)
QString strLanguage = comboLanguage->currentData(Qt::UserRole).toString();
Routino_Profile *profile = Routino_GetProfile(strProfile.toUtf8());
+ if( profile == NULL )
+ {
+ throw tr("Required profile '%1' is not the current profiles file.").arg(strProfile);
+ }
Routino_Translation *translation = Routino_GetTranslation(strLanguage.toUtf8());
int res = Routino_ValidateProfile(data, profile);
@@ -466,6 +470,10 @@ int CRouterRoutino::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& c
QString strLanguage = comboLanguage->currentData(Qt::UserRole).toString();
Routino_Profile *profile = Routino_GetProfile(strProfile.toUtf8());
+ if( profile == NULL )
+ {
+ throw tr("Required profile '%1' is not the current profiles file.").arg(strProfile);
+ }
Routino_Translation *translation = Routino_GetTranslation(strLanguage.toUtf8());