diff options
author | steven_s <steven_s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-10-30 01:46:32 +0000 |
---|---|---|
committer | steven_s <steven_s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-10-30 01:46:32 +0000 |
commit | bc099f9bfc83056d502714b8162d66c5d86a63f7 (patch) | |
tree | d4160b61300e86c85daec94350c0497a622724de /navit/mapset.c | |
parent | eedb98248a5bb9da70b617333134854afc1fa38e (diff) | |
download | navit-svn-bc099f9bfc83056d502714b8162d66c5d86a63f7.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.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/navit/mapset.c b/navit/mapset.c index 5ebec023..e1a8f61e 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 (;;) { |