Skip to content

Bug in convertInternalLatLonToString #723

@perrygeo

Description

@perrygeo

The convertInternalLatLonToString function creates a char buffer with a null terminator at 10 which does not work properly for longitudes <= -100 .

This manifests itself in the nearest web service where full coordinates are not returned. See http://lists.openstreetmap.org/pipermail/osrm-talk/2013-August/000239.html . The longitude string is blank.

The following simple patch seems to fix it. Will this work?

diff --git a/DataStructures/Coordinate.h b/DataStructures/Coordinate.h
index bf0d3ea..02e7fc6 100644
--- a/DataStructures/Coordinate.h
+++ b/DataStructures/Coordinate.h
@@ -118,8 +118,8 @@ inline double ApproximateEuclideanDistance(const FixedPointCoordinate &c1, const

 static inline void convertInternalLatLonToString(const int value, std::string & output) {
     char buffer[100];
-    buffer[10] = 0; // Nullterminierung
-    char* string = printInt< 10, 6 >( buffer, value );
+    buffer[11] = 0; // Nullterminierung
+    char* string = printInt< 11, 6 >( buffer, value );
     output = string;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions