From 1ec7448cb08f1cc2917b33e3337946a8da23208f Mon Sep 17 00:00:00 2001 From: Darth Vader Date: Tue, 11 Jun 2024 00:57:31 +0000 Subject: [PATCH] Squashed 'src/' changes from 2b17f7ca..279b8435 279b8435 [iphreeqc] Fixed for R git-subtree-dir: src git-subtree-split: 279b84357dd36426396d7916436c373d319d2082 --- phreeqcpp/Serializer.cxx | 4 ++++ phreeqcpp/common/Utils.cxx | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/phreeqcpp/Serializer.cxx b/phreeqcpp/Serializer.cxx index b4ebab76..fab11a37 100644 --- a/phreeqcpp/Serializer.cxx +++ b/phreeqcpp/Serializer.cxx @@ -201,6 +201,10 @@ Serializer::Deserialize(Phreeqc &phreeqc_ref, Dictionary &dictionary, std::vecto #if !defined(R_SO) std::cerr << "Unknown pack type in deserialize " << type << std::endl; exit(4); +#else + std::ostringstream oss; + oss << "Unknown pack type in deserialize " << type << std::endl; + phreeqc_ref.error_msg(oss.str().c_str(), STOP); #endif break; } diff --git a/phreeqcpp/common/Utils.cxx b/phreeqcpp/common/Utils.cxx index 6738fa9d..b2585a56 100644 --- a/phreeqcpp/common/Utils.cxx +++ b/phreeqcpp/common/Utils.cxx @@ -199,13 +199,17 @@ strcpy_safe(char* dest, size_t max, const char* src) { if (dest == nullptr || src == nullptr) { +#if !defined(R_SO) std::cerr << "nullptr in Utilities::strcpy_safe." << std::endl; +#endif throw; } lsrc = strlen(src); if (lsrc + 1 > max) { +#if !defined(R_SO) std::cerr << "Buffer overrun in Utilities::strcpy_safe." << std::endl; +#endif throw; } memcpy(dest, src, (lsrc + 1) * sizeof(char)); @@ -224,14 +228,18 @@ strcat_safe(char* dest, size_t max, const char* src) { if (dest == nullptr || src == nullptr) { +#if !defined(R_SO) std::cerr << "nullptr in Utilities::strcat_safe." << std::endl; +#endif throw; } lsrc = strlen(src); ldest = strlen(dest); if (ldest + lsrc + 1 > max) { +#if !defined(R_SO) std::cerr << "Buffer overrun in Utilities::strcat_safe." << std::endl; +#endif throw; } memcpy(&dest[ldest], src, (lsrc + 1) * sizeof(char));