From 1ec2064efc7ab25de2c163b0f6263045a79cbbea Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Mon, 27 Mar 2006 15:17:52 +0000 Subject: [PATCH] libi2ncommon: (tomj) throw exception if replace_all is called with empty search string (leads to OOM otherwise) --- src/stringfunc.cpp | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/stringfunc.cpp b/src/stringfunc.cpp index dcc1cde..199b277 100644 --- a/src/stringfunc.cpp +++ b/src/stringfunc.cpp @@ -162,6 +162,9 @@ bool replace_all(string &base, const string &ist, const string &soll) bool found_ist = false; string::size_type a=0; + if (ist.empty()) + throw runtime_error("replace_all called with empty search string"); + while((a=base.find(ist,a))!=string::npos) { base.replace(a,ist.size(),soll); -- 1.7.1