Good morning all,
I used regex library which is shipped with boost 1.30 in my project. But
I found in the case I list below, the regex_match() will crash. Is there
a pitfall in it?
===================== CODE LIST BEGIN =========================
#include "stdafx.h"
#include
#include
using namespace boost;
void do_regex_match(const string& s)
{
USES_CONVERSION;
CString _c1,_c2;
_c1 = "\\_gl_glcf]a:(D_N~yOA_gg_aeN_o/>jm_gf'0(m_--\\6L_gi_AE_gd5<&0A~_E'_Y-'-,uO7_so_glTc G_gl_C,_o/*6hC=@_u"; // Failed
_c2 = "\\_gl_glcf]a:(D_N~yOA_gg_aeN_o/jm_gf'0(m_--\\6L_gi_AE_gd5<&0A~_E'_Y-'-,uO7_so_glTc G_gl_C,_o/*6hC=@_u"; // Passed
wstring ws1(L""),ws2(L"");
ws1=A2W(_c1);
ws2=A2W(_c2);
wstring wsMatchString(L"");
wsMatchString=A2W(".*(要)?.*天气.*");
boost::wregex e(wsMatchString/*,boost::regbase::normal|boost::regbase::icase*/);
boost::regex_match(ws2,e);// Pass
boost::regex_match(ws1,e);// Crash
}
======================== CODE LIST END =========================
As you can see in the code, if any change is made to _c1, the test will
pass or it will crash. I will list my compiler and system information
below.
Compiler: Microsoft Visual C++ 6.0 Professionall with SP5
OS: Microsoft Windows 2000 Professional with SP3
RAM: 512M
CPU: PIII 700
Any help will be appreciated.
Phipps Xue
Software Engineer, MCP/MCSD
Email: xuejm@sina.com