Skip to content

Commit 9ad13a6

Browse files
nryengdahlerlend
authored andcommitted
Bug #27672683 CREATE SPATIAL REFERENCE:ASSERTION FAILED: "STANDARD C++
LIBRARIES OUT OF RANGE" Problem: CREATE SPATIAL REFERENCE SYSTEM with an empty definition string causes printouts from STL assertions on Windows debug builds because front() and back() are called on an empty string. Solution: Use data() and size() instead of front() and back() and make the invalid/empty string checks in gis::srs::parse_wkt() more robust. Covered by existing tests in gis.srs. No new testcase needed. Change-Id: Iebbf7a0b523b098d56a04f0f2db829f52082f2cb
1 parent fb9c110 commit 9ad13a6

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

sql/dd/impl/types/spatial_reference_system_impl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ bool Spatial_reference_system_impl::deserialize(Sdi_rcontext *rctx,
171171
bool Spatial_reference_system_impl::parse_definition() {
172172
gis::srs::Spatial_reference_system *srs = nullptr;
173173
// parse_wkt() will only allocate memory if successful.
174-
if (!gis::srs::parse_wkt(id(), &m_definition.front(),
175-
&m_definition.back() + 1, &srs)) {
174+
if (!gis::srs::parse_wkt(id(), m_definition.data(),
175+
m_definition.data() + m_definition.size(), &srs)) {
176176
m_parsed_definition.reset(srs);
177177
return false;
178178
}

sql/gis/srs/srs.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
22
//
33
// This program is free software; you can redistribute it and/or modify
44
// it under the terms of the GNU General Public License, version 2.0,
@@ -1043,7 +1043,7 @@ static bool create_projected_srs(gis::srid_t srid,
10431043

10441044
bool gis::srs::parse_wkt(gis::srid_t srid, const char *begin, const char *end,
10451045
Spatial_reference_system **result) {
1046-
if (begin == nullptr || begin == end) {
1046+
if (begin == nullptr || begin >= (end - 1)) {
10471047
my_error(ER_SRS_PARSE_ERROR, MYF(0), srid);
10481048
return true;
10491049
}

sql/gis/srs/srs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef SQL_GIS_SRS_SRS_H_INCLUDED
22
#define SQL_GIS_SRS_SRS_H_INCLUDED
33

4-
// Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
4+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
55
//
66
// This program is free software; you can redistribute it and/or modify
77
// it under the terms of the GNU General Public License, version 2.0,
@@ -1796,7 +1796,7 @@ class Lambert_cylindrical_equal_area_srs : public Projected_srs {
17961796
17971797
@param[in] srid Spatial reference system ID to use when reporting errors
17981798
@param[in] begin Start of WKT string in UTF-8
1799-
@param[in] end End of WKT string
1799+
@param[in] end End of WKT string (one past the last byte)
18001800
@param[out] result Spatial reference system
18011801
18021802
@retval true An error has occurred

sql/gis/srs/wkt_parser.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
1+
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
22
//
33
// This program is free software; you can redistribute it and/or modify
44
// it under the terms of the GNU General Public License, version 2.0,
@@ -241,7 +241,7 @@ bool gis::srs::wkt_parser::parse_wkt(
241241
srid_t srid, const char *begin, const char *end,
242242
gis::srs::wkt_parser::Coordinate_system *cs) {
243243
// gis::srs::parse_wkt() should have filtered these out already
244-
DBUG_ASSERT(begin != nullptr && begin != end);
244+
DBUG_ASSERT(begin != nullptr && begin < (end - 1));
245245

246246
namespace wp = gis::srs::wkt_parser;
247247

0 commit comments

Comments
 (0)