[iphreeqc] Fixed for R

This commit is contained in:
Charlton, Scott R 2024-06-10 18:55:01 -06:00
parent 8dbfe3bddb
commit 53d7a25636
2 changed files with 12 additions and 0 deletions

View File

@ -201,6 +201,10 @@ Serializer::Deserialize(Phreeqc &phreeqc_ref, Dictionary &dictionary, std::vecto
#if !defined(R_SO) #if !defined(R_SO)
std::cerr << "Unknown pack type in deserialize " << type << std::endl; std::cerr << "Unknown pack type in deserialize " << type << std::endl;
exit(4); 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 #endif
break; break;
} }

View File

@ -199,13 +199,17 @@ strcpy_safe(char* dest, size_t max, const char* src)
{ {
if (dest == nullptr || src == nullptr) if (dest == nullptr || src == nullptr)
{ {
#if !defined(R_SO)
std::cerr << "nullptr in Utilities::strcpy_safe." << std::endl; std::cerr << "nullptr in Utilities::strcpy_safe." << std::endl;
#endif
throw; throw;
} }
lsrc = strlen(src); lsrc = strlen(src);
if (lsrc + 1 > max) if (lsrc + 1 > max)
{ {
#if !defined(R_SO)
std::cerr << "Buffer overrun in Utilities::strcpy_safe." << std::endl; std::cerr << "Buffer overrun in Utilities::strcpy_safe." << std::endl;
#endif
throw; throw;
} }
memcpy(dest, src, (lsrc + 1) * sizeof(char)); 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 (dest == nullptr || src == nullptr)
{ {
#if !defined(R_SO)
std::cerr << "nullptr in Utilities::strcat_safe." << std::endl; std::cerr << "nullptr in Utilities::strcat_safe." << std::endl;
#endif
throw; throw;
} }
lsrc = strlen(src); lsrc = strlen(src);
ldest = strlen(dest); ldest = strlen(dest);
if (ldest + lsrc + 1 > max) if (ldest + lsrc + 1 > max)
{ {
#if !defined(R_SO)
std::cerr << "Buffer overrun in Utilities::strcat_safe." << std::endl; std::cerr << "Buffer overrun in Utilities::strcat_safe." << std::endl;
#endif
throw; throw;
} }
memcpy(&dest[ldest], src, (lsrc + 1) * sizeof(char)); memcpy(&dest[ldest], src, (lsrc + 1) * sizeof(char));