From 5b08f7369fbcfc3afdd3791bd0e0201a928aae90 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 9 Sep 2015 22:58:22 +0000 Subject: [PATCH] limit PhysicalNames to 128 chars --- Geo/GModelIO_MSH.cpp | 7 +++++-- Geo/GModelIO_MSH2.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Geo/GModelIO_MSH.cpp b/Geo/GModelIO_MSH.cpp index ace1af9d50..22ecb854d8 100644 --- a/Geo/GModelIO_MSH.cpp +++ b/Geo/GModelIO_MSH.cpp @@ -526,9 +526,12 @@ int GModel::writeMSH(const std::string &name, double version, bool binary, if(numPhysicalNames()){ fprintf(fp, "$PhysicalNames\n"); fprintf(fp, "%d\n", numPhysicalNames()); - for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++) + for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++){ + std::string name = it->second; + if(name.size() > 254) name.resize(254); fprintf(fp, "%d %d \"%s\"\n", it->first.first, it->first.second, - it->second.c_str()); + name.c_str()); + } fprintf(fp, "$EndPhysicalNames\n"); } diff --git a/Geo/GModelIO_MSH2.cpp b/Geo/GModelIO_MSH2.cpp index 560fbd83c4..dd77c6a8e4 100644 --- a/Geo/GModelIO_MSH2.cpp +++ b/Geo/GModelIO_MSH2.cpp @@ -895,9 +895,12 @@ int GModel::_writeMSH2(const std::string &name, double version, bool binary, if(numPhysicalNames()){ fprintf(fp, "$PhysicalNames\n"); fprintf(fp, "%d\n", numPhysicalNames()); - for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++) + for(piter it = firstPhysicalName(); it != lastPhysicalName(); it++){ + std::string name = it->second; + if(name.size() > 128) name.resize(128); fprintf(fp, "%d %d \"%s\"\n", it->first.first, it->first.second, - it->second.c_str()); + name.c_str()); + } fprintf(fp, "$EndPhysicalNames\n"); } -- GitLab