mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-16 00:50:40 +01:00
* fixed a possible chm compiler crash when a chm without .ht* files is created but full search is enabled.
git-svn-id: trunk@15573 -
This commit is contained in:
parent
2796b58cfd
commit
28041f3e3f
@ -86,11 +86,13 @@ type
|
||||
FStream: TStream;
|
||||
FWordList: TIndexedWordList;
|
||||
FActiveLeafNode: TFIftiNode;
|
||||
function GetHasData: Boolean;
|
||||
procedure ProcessWords;
|
||||
procedure WriteHeader(IsPlaceHolder: Boolean);
|
||||
procedure WriteAWord(AWord: TIndexedWord);
|
||||
public
|
||||
procedure WriteToStream;
|
||||
property HasData: Boolean read GetHasData;
|
||||
constructor Create(AStream: TStream; AWordList: TIndexedWordList);
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
@ -261,6 +263,11 @@ begin
|
||||
FActiveLeafNode.Flush(False); // causes the unwritten parts of the tree to be written
|
||||
end;
|
||||
|
||||
function TChmSearchWriter.GetHasData: Boolean;
|
||||
begin
|
||||
Result := FActiveLeafNode <> nil;
|
||||
end;
|
||||
|
||||
|
||||
procedure TChmSearchWriter.WriteHeader ( IsPlaceHolder: Boolean ) ;
|
||||
var
|
||||
|
||||
@ -137,6 +137,7 @@ Type
|
||||
FDefaultFont: String;
|
||||
FDefaultPage: String;
|
||||
FFullTextSearch: Boolean;
|
||||
FFullTextSearchAvailable: Boolean;
|
||||
FSearchTitlesOnly: Boolean;
|
||||
FStringsStream: TMemoryStream; // the #STRINGS file
|
||||
FTopicsStream: TMemoryStream; // the #TOPICS file
|
||||
@ -970,7 +971,7 @@ begin
|
||||
|
||||
FSection0.WriteDWord(NToLE(DWord($0409)));
|
||||
FSection0.WriteDWord(1);
|
||||
FSection0.WriteDWord(NToLE(DWord(Ord(FFullTextSearch))));
|
||||
FSection0.WriteDWord(NToLE(DWord(Ord(FFullTextSearch and FFullTextSearchAvailable))));
|
||||
FSection0.WriteDWord(0);
|
||||
FSection0.WriteDWord(0);
|
||||
|
||||
@ -1256,6 +1257,14 @@ begin
|
||||
if FTopicsStream.Size = 0 then
|
||||
Exit;
|
||||
SearchWriter := TChmSearchWriter.Create(FFiftiMainStream, FIndexedFiles);
|
||||
// do not add an empty $FIftiMain
|
||||
if not SearchWriter.HasData then
|
||||
begin
|
||||
FFullTextSearchAvailable := False;
|
||||
SearchWriter.Free;
|
||||
Exit;
|
||||
end;
|
||||
FFullTextSearchAvailable := True;
|
||||
SearchWriter.WriteToStream;
|
||||
SearchWriter.Free;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user