This commit is contained in:
Matthias Köfferlein 2021-08-24 21:37:15 +02:00 committed by GitHub
parent 225d3ab32d
commit 93e789a861
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 3 deletions

View File

@ -208,10 +208,13 @@ GDS2Reader::get_string (std::string &s) const
{
if (m_reclen == 0) {
s.clear ();
} else if (mp_rec_buf [m_reclen - 1] != 0) {
s.assign ((const char *) mp_rec_buf, m_reclen);
} else {
s.assign ((const char *) mp_rec_buf, m_reclen - 1);
// strip padding 0 characters
unsigned long n = m_reclen;
while (n > 0 && mp_rec_buf [n - 1] == 0) {
--n;
}
s.assign ((const char *) mp_rec_buf, n);
}
}

View File

@ -685,3 +685,22 @@ TEST(4_CollectModeAdd)
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
}
// border case with multiple padding 0 for SNAME and STRING records
TEST(5_issue893)
{
db::Manager m (false);
db::Layout layout (&m);
db::LoadLayoutOptions options;
options.get_options<db::CommonReaderOptions> ().cell_conflict_resolution = db::AddToCell;
{
tl::InputStream file (tl::testdata () + "/gds/issue_893.gds");
db::Reader reader (file);
reader.read (layout, options);
}
std::string fn_au (tl::testdata () + "/gds/issue_893_au.gds");
db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1);
}

BIN
testdata/gds/issue_893.gds vendored Normal file

Binary file not shown.

BIN
testdata/gds/issue_893_au.gds vendored Normal file

Binary file not shown.