From b5f880ba1df83dc8bfa7a8384cff364677589a01 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 28 Jun 2016 16:03:01 +0100 Subject: [PATCH] Replaced unsafe c string usage with std::string --- src/osgPlugins/txp/trpage_header.cpp | 4 ++-- src/osgPlugins/txp/trpage_io.h | 4 ++-- src/osgPlugins/txp/trpage_light.cpp | 2 +- src/osgPlugins/txp/trpage_material.cpp | 4 ++-- src/osgPlugins/txp/trpage_model.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/osgPlugins/txp/trpage_header.cpp b/src/osgPlugins/txp/trpage_header.cpp index 3c267f699..3bc590a05 100644 --- a/src/osgPlugins/txp/trpage_header.cpp +++ b/src/osgPlugins/txp/trpage_header.cpp @@ -50,12 +50,12 @@ bool trpgHeader::isValid() const else { if (numLods <= 0) { - strcpy(errMess, "Number of LOD <= 0"); + errMess.assign("Number of LOD <= 0"); return false; } if (sw.x == ne.x && sw.y == ne.y) { - strcpy(errMess, "Mbr is invalid"); + errMess.assign("Mbr is invalid"); return false; } diff --git a/src/osgPlugins/txp/trpage_io.h b/src/osgPlugins/txp/trpage_io.h index 2f123645d..34d457dc6 100644 --- a/src/osgPlugins/txp/trpage_io.h +++ b/src/osgPlugins/txp/trpage_io.h @@ -618,11 +618,11 @@ public: */ virtual bool Print(trpgPrintBuffer &) const { return true; } - const char *getErrMess() const {if(errMess[0] == '\0') return 0;else return &errMess[0];} + const char *getErrMess() const { return errMess.empty() ? 0 : errMess.c_str();} protected: - mutable char errMess[512]; + mutable std::string errMess; }; /* Pointer into a trpgwAppFile. The full name of the file diff --git a/src/osgPlugins/txp/trpage_light.cpp b/src/osgPlugins/txp/trpage_light.cpp index bbae49d3b..e110788f3 100644 --- a/src/osgPlugins/txp/trpage_light.cpp +++ b/src/osgPlugins/txp/trpage_light.cpp @@ -949,7 +949,7 @@ bool trpgLightTable::isValid() const if (!itr->second.isValid()) { if(itr->second.getErrMess()) - strcpy(errMess, itr->second.getErrMess()); + errMess.assign(itr->second.getErrMess()); return false; } } diff --git a/src/osgPlugins/txp/trpage_material.cpp b/src/osgPlugins/txp/trpage_material.cpp index 01f0deda2..5828c6b32 100644 --- a/src/osgPlugins/txp/trpage_material.cpp +++ b/src/osgPlugins/txp/trpage_material.cpp @@ -1629,14 +1629,14 @@ bool trpgTexTable::isValid() const { if (!textureMap.size()) { - strcpy(errMess, "Texture table list is empty"); + errMess.assign("Texture table list is empty"); return false; } TextureMapType::const_iterator itr = textureMap.begin(); for ( ; itr != textureMap.end( ); itr++) { if(!itr->second.isValid()) { - strcpy(errMess, "A texture in the texture table is invalid"); + errMess.assign("A texture in the texture table is invalid"); return false; } } diff --git a/src/osgPlugins/txp/trpage_model.cpp b/src/osgPlugins/txp/trpage_model.cpp index 6c5d1a910..77326fd13 100644 --- a/src/osgPlugins/txp/trpage_model.cpp +++ b/src/osgPlugins/txp/trpage_model.cpp @@ -111,7 +111,7 @@ bool trpgModel::isValid() const { if (type == External && !name) { - strcpy(errMess, "Model is external with no name"); + errMess.assign("Model is external with no name"); return false; } @@ -375,7 +375,7 @@ bool trpgModelTable::isValid() const for ( ; itr != modelsMap.end( ); itr++) { if(!itr->second.isValid()) { if(itr->second.getErrMess()) - strcpy(errMess, itr->second.getErrMess()); + errMess.assign(itr->second.getErrMess()); return false; } }