فهرست منبع

FIX: Viewer - crash with an invalid regular expression

Alexander Koblov 3 ماه پیش
والد
کامیت
e96a6460b4
1فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  1. 10 2
      src/fviewer.pas

+ 10 - 2
src/fviewer.pas

@@ -3364,8 +3364,16 @@ begin
     if FFindDialog.cbRegExp.Checked then
     begin
       FRegExp.ModifierI:= not FFindDialog.cbCaseSens.Checked;
-      FRegExp.Expression:= sSearchTextU;
-      bTextFound:= FRegExp.Exec(FLastSearchPos + FLastMatchLength + 1);
+      try
+        FRegExp.Expression:= sSearchTextU;
+        bTextFound:= FRegExp.Exec(FLastSearchPos + FLastMatchLength + 1);
+      except
+        on E: Exception do
+        begin
+          msgError(StripHotkey(FFindDialog.cbRegExp.Caption) + ': ' + E.Message);
+          Exit;
+        end;
+      end;
       if bTextFound then
       begin
         FLastMatchLength:= FRegExp.MatchLen[0];