mirror of
https://github.com/glest/glest-source.git
synced 2025-08-16 13:23:59 +02:00
- check for empty strings before using substr to avoid crashes with more strict C++ engine
This commit is contained in:
@@ -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