mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 21:04:00 +02:00
- check for empty strings before using substr to avoid crashes with more strict C++ engine
This commit is contained in:
@@ -270,23 +270,6 @@ int64 Chrono::getCurTicks() {
|
||||
// =====================================
|
||||
|
||||
void Tokenize(const string& str,vector<string>& tokens,const string& delimiters) {
|
||||
|
||||
/*
|
||||
// Skip delimiters at beginning.
|
||||
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
||||
// Find first "non-delimiter".
|
||||
string::size_type pos = str.find_first_of(delimiters, lastPos);
|
||||
|
||||
while (string::npos != pos || string::npos != lastPos) {
|
||||
// Found a token, add it to the vector.
|
||||
tokens.push_back(str.substr(lastPos, pos - lastPos));
|
||||
// Skip delimiters. Note the "not_of"
|
||||
lastPos = str.find_first_not_of(delimiters, pos);
|
||||
// Find next "non-delimiter"
|
||||
pos = str.find_first_of(delimiters, lastPos);
|
||||
}
|
||||
*/
|
||||
|
||||
// Assume textLine contains the line of text to parse.
|
||||
string textLine = str;
|
||||
|
||||
|
@@ -301,15 +301,17 @@ Ip::Ip(unsigned char byte0, unsigned char byte1, unsigned char byte2, unsigned c
|
||||
}
|
||||
|
||||
|
||||
Ip::Ip(const string& ipString){
|
||||
Ip::Ip(const string &ipString) {
|
||||
size_t offset= 0;
|
||||
int byteIndex= 0;
|
||||
|
||||
for(byteIndex= 0; byteIndex<4; ++byteIndex){
|
||||
size_t dotPos= ipString.find_first_of('.', offset);
|
||||
if(ipString.empty() == false) {
|
||||
for(byteIndex= 0; byteIndex<4; ++byteIndex){
|
||||
size_t dotPos= ipString.find_first_of('.', offset);
|
||||
|
||||
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
|
||||
offset= dotPos+1;
|
||||
bytes[byteIndex]= atoi(ipString.substr(offset, dotPos-offset).c_str());
|
||||
offset= dotPos+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user