summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/DynamicLibrary.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2013-06-27 11:12:58 +0200
committerBenoit Foucher <benoit@zeroc.com>2013-06-27 11:12:58 +0200
commite40c00eaabd62e0650bc75a7cb72b4424d0e280b (patch)
tree016cf0d5a6ce62a373139afa3dca609b733cf9ac /cpp/src/Ice/DynamicLibrary.cpp
parentRemoved PropertiesAdmin.h from repository, it's now generated (diff)
downloadice-e40c00eaabd62e0650bc75a7cb72b4424d0e280b.tar.bz2
ice-e40c00eaabd62e0650bc75a7cb72b4424d0e280b.tar.xz
ice-e40c00eaabd62e0650bc75a7cb72b4424d0e280b.zip
Fixed ICE-5363: unexpected string::substr exception thrown
Diffstat (limited to 'cpp/src/Ice/DynamicLibrary.cpp')
-rw-r--r--cpp/src/Ice/DynamicLibrary.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
index b0ff87016e0..780083f408e 100644
--- a/cpp/src/Ice/DynamicLibrary.cpp
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -65,9 +65,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
}
#endif
- string::size_type comma = entryPoint.find(',');
- if(colon == string::npos || colon == entryPoint.size() - 1 ||
- (comma != string::npos && (comma > colon || comma == colon - 1)))
+ if(colon == string::npos || colon == entryPoint.size() - 1)
{
_err = "invalid entry point format `" + entryPoint + "'";
return 0;
@@ -78,22 +76,17 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
string libPath, libName, version, debug;
#ifdef _WIN32
- bool isFilePath = libSpec.find('\\') != string::npos || entryPoint.find('/') != string::npos;
+ string::size_type separator = libSpec.find_last_of("/\\");
#else
- bool isFilePath = libSpec.find('/') != string::npos;
+ string::size_type separator = libSpec.rfind('/');
#endif
-
- if(isFilePath)
+ if(separator != string::npos)
{
-#ifdef _WIN32
- string::size_type separator = libSpec.find_last_of("/\\");
-#else
- string::size_type separator = libSpec.rfind('/');
-#endif
libPath = libSpec.substr(0, separator + 1);
libSpec = libSpec.substr(separator + 1);
}
+ string::size_type comma = libSpec.find(',');
if(comma == string::npos)
{
libName = libSpec;
@@ -118,6 +111,11 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
}
else
{
+ if(comma == libSpec.size() - 1)
+ {
+ _err = "invalid entry point format `" + entryPoint + "'";
+ return 0;
+ }
libName = libSpec.substr(0, comma);
version = libSpec.substr(comma + 1);
}