mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
fix: crash in OpenTextFile, for a 0-bytes file - override the encoding to one without BOM
Closes #1448
This commit is contained in:
@@ -1331,6 +1331,9 @@ begin
|
||||
Stream := TFileStream.Create(Filename, fmOpenRead or fmShareDenyNone);
|
||||
if Encoding = nil then
|
||||
Encoding := DetectEncoding(Stream);
|
||||
// For a 0-bytes file, override the encoding to one without BOM
|
||||
if _GetFileSize(Filename) < Length(Encoding.GetPreamble) then
|
||||
Encoding := UTF8NoBOMEncoding;
|
||||
// If the file contains a BOM, advance the stream's position
|
||||
BomLen := 0;
|
||||
if Length(Encoding.GetPreamble) > 0 then begin
|
||||
|
||||
Reference in New Issue
Block a user