summaryrefslogtreecommitdiff
path: root/navit/mapset.c
diff options
context:
space:
mode:
authorsteven_s <steven_s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-10-30 01:46:32 +0000
committersteven_s <steven_s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-10-30 01:46:32 +0000
commit814d3ed976d4fd0d49fc04461e0794c1ff5b3c4a (patch)
treed4160b61300e86c85daec94350c0497a622724de /navit/mapset.c
parent479fa40f464d6a880f9be0a736138062ab4ccc81 (diff)
downloadnavit-814d3ed976d4fd0d49fc04461e0794c1ff5b3c4a.tar.gz
Fix:core: No longer exits or crashes when no mapsets are defined. Ticket #238
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1618 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/mapset.c')
-rw-r--r--navit/mapset.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/navit/mapset.c b/navit/mapset.c
index 5ebec023d..e1a8f61ea 100644
--- a/navit/mapset.c
+++ b/navit/mapset.c
@@ -119,10 +119,12 @@ struct mapset_handle {
struct mapset_handle *
mapset_open(struct mapset *ms)
{
- struct mapset_handle *ret;
-
- ret=g_new(struct mapset_handle, 1);
- ret->l=ms->maps;
+ struct mapset_handle *ret=NULL;
+ if(ms)
+ {
+ ret=g_new(struct mapset_handle, 1);
+ ret->l=ms->maps;
+ }
return ret;
}
@@ -143,7 +145,7 @@ struct map * mapset_next(struct mapset_handle *msh, int active)
struct attr active_attr;
for (;;) {
- if (!msh->l)
+ if (!msh || !msh->l)
return NULL;
ret=msh->l->data;
msh->l=g_list_next(msh->l);
@@ -207,12 +209,19 @@ mapset_search_new(struct mapset *ms, struct item *item, struct attr *search_attr
struct mapset_search *this;
dbg(1,"enter(%p,%p,%p,%d)\n", ms, item, search_attr, partial);
this=g_new0(struct mapset_search,1);
- this->map=ms->maps;
- this->item=item;
- this->search_attr=search_attr;
- this->partial=partial;
- this->ms=map_search_new(this->map->data, item, search_attr, partial);
- return this;
+ if(this != NULL && ms!=NULL )
+ {
+ this->map=ms->maps;
+ this->item=item;
+ this->search_attr=search_attr;
+ this->partial=partial;
+ this->ms=map_search_new(this->map->data, item, search_attr, partial);
+ return this;
+ }
+ else
+ {
+ return NULL;
+ }
}
/**
@@ -231,7 +240,7 @@ mapset_search_get_item(struct mapset_search *this)
struct item *ret=NULL;
struct attr active_attr;
- while (!this->ms || !(ret=map_search_get_item(this->ms))) { /* The current map has no more items to be returned */
+ while ((this) && (!this->ms || !(ret=map_search_get_item(this->ms)))) { /* The current map has no more items to be returned */
if (this->search_attr->type >= attr_country_all && this->search_attr->type <= attr_country_name)
break;
for (;;) {