diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-02-25 13:58:21 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-02-25 13:58:21 +0000 |
commit | d1816967a16376be5f11542df4106e2c38385357 (patch) | |
tree | 74f48bda16c15b109351e5451eb5be77d5e55d06 | |
parent | 35efad49ef5cfafa31c000c64702729ba3001155 (diff) | |
download | navit-d1816967a16376be5f11542df4106e2c38385357.tar.gz |
Fix:osd_core:Prevent a crash
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2072 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | navit/osd/core/osd_core.c | 10 | ||||
-rw-r--r-- | navit/track.c | 8 | ||||
-rw-r--r-- | navit/track.h | 1 |
3 files changed, 13 insertions, 6 deletions
diff --git a/navit/osd/core/osd_core.c b/navit/osd/core/osd_core.c index bfaf7a675..7df3c48d3 100644 --- a/navit/osd/core/osd_core.c +++ b/navit/osd/core/osd_core.c @@ -890,7 +890,7 @@ osd_text_draw(struct osd_text *this, struct navit *navit, struct vehicle *v) struct point p, p2[4]; char *str,*next,*start,*end,*key,*subkey,*index,*value; int do_draw = 0; - struct attr attr, vehicle_attr, flags_attr, maxspeed_attr; + struct attr attr, vehicle_attr, maxspeed_attr; struct navigation *nav = NULL; struct tracking *tracking = NULL; struct route *route = NULL; @@ -964,11 +964,9 @@ osd_text_draw(struct osd_text *this, struct navit *navit, struct vehicle *v) item=tracking_get_current_item(tracking); if (item && !strcmp(key,"route_speed")) { double routespeed = -1; - if (item_attr_get(item, attr_flags, &flags_attr) && (flags_attr.u.num & AF_SPEED_LIMIT)) { - if (item_attr_get(item, attr_maxspeed, &maxspeed_attr)) { - routespeed = maxspeed_attr.u.num; - value = format_speed(routespeed, ""); - } + if ((tracking_get_current_flags(tracking) & AF_SPEED_LIMIT) && tracking_get_current_attr(tracking, attr_maxspeed, &maxspeed_attr)) { + routespeed = maxspeed_attr.u.num; + value = format_speed(routespeed, ""); } if ((routespeed == -1) && route && (speedlist=route_get_speedlist(route))) { diff --git a/navit/track.c b/navit/track.c index 071c98fc3..848494c3a 100644 --- a/navit/track.c +++ b/navit/track.c @@ -121,6 +121,14 @@ tracking_get_current_item(struct tracking *_this) return &_this->curr_line->street->item; } +int +tracking_get_current_flags(struct tracking *_this) +{ + if (! _this->curr_line || ! _this->curr_line->street) + return NULL; + return &_this->curr_line->street->flags; +} + static void tracking_get_angles(struct tracking_line *tl) { diff --git a/navit/track.h b/navit/track.h index fe7ef9059..1a2676178 100644 --- a/navit/track.h +++ b/navit/track.h @@ -37,6 +37,7 @@ void tracking_set_mapset(struct tracking *this_, struct mapset *ms); void tracking_set_route(struct tracking *this_, struct route *rt); int tracking_get_current_attr(struct tracking *_this, enum attr_type type, struct attr *attr); struct item *tracking_get_current_item(struct tracking *_this); +int tracking_get_current_flags(struct tracking *_this); void tracking_destroy(struct tracking *tr); struct map * tracking_get_map(struct tracking *this_); void tracking_init(void); |