[libchamplain] Fix crasher if invalid map or rules paths are used



commit 1211fcdc4ab8a11e54d0db5c9ed9b23291e4f65c
Author: Simon Wenner <simon wenner ch>
Date:   Tue Nov 10 22:30:55 2009 +0100

    Fix crasher if invalid map or rules paths are used
    
    This patch is a temporary solution. The next release of memphis will have a proper error handling.

 champlain/champlain-local-map-data-source.c |    7 +++++++
 champlain/champlain-memphis-map-source.c    |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/champlain/champlain-local-map-data-source.c b/champlain/champlain-local-map-data-source.c
index 6935e41..6ed417e 100644
--- a/champlain/champlain-local-map-data-source.c
+++ b/champlain/champlain-local-map-data-source.c
@@ -154,6 +154,13 @@ champlain_local_map_data_source_load_map_data (ChamplainLocalMapDataSource *self
   g_return_if_fail (CHAMPLAIN_IS_LOCAL_MAP_DATA_SOURCE (self)
       && map_path);
 
+  // TODO: Remove test when memphis handles invalid paths properly
+  if (!g_file_test (map_path, G_FILE_TEST_EXISTS))
+    {
+      g_critical("Error: \"%s\" does not exist.", map_path);
+      return;
+    }
+
   ChamplainLocalMapDataSourcePrivate *priv = GET_PRIVATE(self);
   ChamplainBoundingBox *bbox;
   MemphisMap *map = memphis_map_new ();
diff --git a/champlain/champlain-memphis-map-source.c b/champlain/champlain-memphis-map-source.c
index fcaace3..c5db790 100644
--- a/champlain/champlain-memphis-map-source.c
+++ b/champlain/champlain-memphis-map-source.c
@@ -555,6 +555,13 @@ champlain_memphis_map_source_load_rules (
 {
   g_return_if_fail (CHAMPLAIN_IS_MEMPHIS_MAP_SOURCE (self));
 
+  // TODO: Remove test when memphis handles invalid paths properly
+  if (!g_file_test (rules_path, G_FILE_TEST_EXISTS))
+    {
+      g_critical("Error: \"%s\" does not exist.", rules_path);
+      return;
+    }
+
   ChamplainMemphisMapSourcePrivate *priv = GET_PRIVATE (self);
 
   g_static_rw_lock_writer_lock (&MemphisLock);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]