← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2354: catch regex exceptions

 

------------------------------------------------------------
revno: 2354
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-12-19 18:28:07 +0100
message:
  catch regex exceptions
modified:
  dcpp/ADLSearch.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/ADLSearch.cpp'
--- dcpp/ADLSearch.cpp	2010-12-05 17:03:00 +0000
+++ dcpp/ADLSearch.cpp	2010-12-19 17:28:07 +0000
@@ -25,10 +25,11 @@
 #include "DCPlusPlus.h"
 
 #include "ADLSearch.h"
-#include "QueueManager.h"
+
 #include "ClientManager.h"
-
 #include "File.h"
+#include "LogManager.h"
+#include "QueueManager.h"
 #include "SimpleXML.h"
 
 namespace dcpp {
@@ -131,7 +132,11 @@
 	}
 
 	void operator()(boost::regex& r) const {
-		r.assign(s);
+		try {
+			r.assign(s);
+		} catch(const std::runtime_error&) {
+			LogManager::getInstance()->message(str(F_("Invalid ADL Search regular expression: %1%") % s));
+		}
 	}
 
 private:
@@ -196,7 +201,12 @@
 	}
 
 	bool operator()(boost::regex& r) const {
-		return boost::regex_search(s, r);
+		try {
+			return !r.empty() && boost::regex_search(s, r);
+		} catch(const std::runtime_error&) {
+			// most likely a stack overflow, ignore...
+			return false;
+		}
 	}
 
 private: