diff options
author | mvglasow <michael -at- vonglasow.com> | 2018-08-17 22:33:52 +0200 |
---|---|---|
committer | mvglasow <michael -at- vonglasow.com> | 2018-08-17 22:33:52 +0200 |
commit | 229910eb12e22ea43330a6b95c602b448c847a26 (patch) | |
tree | c6ad94e98d71618206793c554b3a2d773ec32c14 | |
parent | f799c89707afd47d4a2547d6383b9b64e5ddac0c (diff) | |
download | navit-229910eb12e22ea43330a6b95c602b448c847a26.tar.gz |
Fix:traffic:Don't crash when dumping a message without location
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r-- | navit/traffic.c | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/navit/traffic.c b/navit/traffic.c index b4265f911..7b2040ec1 100644 --- a/navit/traffic.c +++ b/navit/traffic.c @@ -2810,11 +2810,14 @@ static void traffic_message_dump_to_stderr(struct traffic_message * this_) { return; } - points[0] = this_->location->from; - points[1] = this_->location->at; - points[2] = this_->location->via; - points[3] = this_->location->not_via; - points[4] = this_->location->to; + if (this_->location) { + points[0] = this_->location->from; + points[1] = this_->location->at; + points[2] = this_->location->via; + points[3] = this_->location->not_via; + points[4] = this_->location->to; + } else + memset(&points, 0, sizeof(struct traffic_point *) * 5); dbg(lvl_debug, "id='%s', is_cancellation=%d, is_forecast=%d", this_->id, this_->is_cancellation, this_->is_forecast); @@ -2852,25 +2855,29 @@ static void traffic_message_dump_to_stderr(struct traffic_message * this_) { } /* dump location */ - dbg(lvl_debug, " Location: road_type='%s', road_ref='%s', road_name='%s'", - item_to_name(this_->location->road_type), this_->location->road_ref, - this_->location->road_name); - dbg(lvl_debug, " directionality=%d, destination='%s', direction='%s'", - this_->location->directionality, this_->location->destination, this_->location->direction); - dbg(lvl_debug, " fuzziness=%s, ramps=%s, tmc_table='%s', tmc_direction=%+d", - location_fuzziness_to_string(this_->location->fuzziness), - location_ramps_to_string(this_->location->ramps), this_->location->tmc_table, - this_->location->tmc_direction); - for (i = 0; i < 5; i++) { - if (points[i]) { - dbg(lvl_debug, " %s: lat=%.5f, lng=%.5f", - point_names[i], points[i]->coord.lat, points[i]->coord.lng); - dbg(lvl_debug, " junction_name='%s', junction_ref='%s', tmc_id='%s'", - points[i]->junction_name, points[i]->junction_ref, points[i]->tmc_id); - } else { - dbg(lvl_debug, " %s: (null)", - point_names[i]); + if (this_->location) { + dbg(lvl_debug, " Location: road_type='%s', road_ref='%s', road_name='%s'", + item_to_name(this_->location->road_type), this_->location->road_ref, + this_->location->road_name); + dbg(lvl_debug, " directionality=%d, destination='%s', direction='%s'", + this_->location->directionality, this_->location->destination, this_->location->direction); + dbg(lvl_debug, " fuzziness=%s, ramps=%s, tmc_table='%s', tmc_direction=%+d", + location_fuzziness_to_string(this_->location->fuzziness), + location_ramps_to_string(this_->location->ramps), this_->location->tmc_table, + this_->location->tmc_direction); + for (i = 0; i < 5; i++) { + if (points[i]) { + dbg(lvl_debug, " %s: lat=%.5f, lng=%.5f", + point_names[i], points[i]->coord.lat, points[i]->coord.lng); + dbg(lvl_debug, " junction_name='%s', junction_ref='%s', tmc_id='%s'", + points[i]->junction_name, points[i]->junction_ref, points[i]->tmc_id); + } else { + dbg(lvl_debug, " %s: (null)", + point_names[i]); + } } + } else { + dbg(lvl_debug, " Location: null"); } /* dump events */ |