wxWidget::wxWebView->Find wxWEBVIEW_FIND_HIGHLIGHT_RESULT Segmentation Fault

Viewed 132

wxWidget::wxWebView->Find - https://docs.wxwidgets.org/3.0/classwx_web_view.html#ad85a7aa0351b6e6a6bffd4220f9758ee

Sample Code

wxWebView *webView;
webView = wxWebView::New(this, wxID_ANY);
webView->SetPage("<html><head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no' /><meta content='en-us' http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><title>Demo App</title><style type=\"text/css\">.auto-style8 {font-family: \"Bookman Old Style\";font-weight:bold;color:#734024;}.underline{color:#ff0000;}.text {color:#230fd2;}#wrapper1 {    width: 100% ; display: table;}#wrapper {width: 100% ; display: table;}#header1 {color: #E6F0F1;    display: table;    background-color: #0000ff;width: 100% ; text-align: center;height: 50px;font-size: 105% ; font-weight: bold;}#header2 {background-color: #B98264;display: table;    width: 100% ; height: 40px;text-align: center;color: #FFFFFF;    font-size: 75% ; font-weight: bold;}.auto-style13 {text-decoration: underline;}.text2{color:#000000;text-align: justify;}</style></head> <body style=\"color:#000000;background-color:#FFFFFF\"><div id=\"header2\"><p style=\"font-size: x-medium\" class=\"auto-style13\">Demo Page<br></p></div> <p class=\"auto-style8\" style=\"width: 100%;\">To Start  - <br/><br/>STEP 1. Select data</p></body></html>","");
long lMatchCount = webView->Find("a",wxWEBVIEW_FIND_HIGHLIGHT_RESULT  );
        if(lMatchCount == wxNOT_FOUND){
            wxMessageBox("Search not found");
        }else{
            //wxMessageBox("Search found" + lMatchCount);
            wxLogMessage("Matches: %s ",std::to_string(lMatchCount));
        }

Above code works correctly and returns number of occurrences of "a".

When webview->SetPage is updated again dynamically with large text ( any dummy content will do ) and if find call is called again it crashes with Segmentation fault

If SetPage is loaded with large text in 1st instance itself it crashes as well so ruled out possibility of update causing the crash.

Also tried loading large file from local file ( default.html contains above html code - replace any long string and it crashes with same result )

wxFile fFileIn("default.html", wxFile::read); 
wxFileInputStream in(fFileIn);
webView->SetPage(in,"");
fFileIn.Close();

Similar issue is reported here http://trac.wxwidgets.org/ticket/15207

1 Answers
Related