mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 18:12:05 +08:00
Add safety check for numeric history item name, so we don't run into follow up errors when there is some non-numeric history item. Fixes issue #2790.
This commit is contained in:
@ -83,7 +83,7 @@ type
|
|||||||
FMaxDuration: Cardinal;
|
FMaxDuration: Cardinal;
|
||||||
public
|
public
|
||||||
property MaxDuration: Cardinal read FMaxDuration;
|
property MaxDuration: Cardinal read FMaxDuration;
|
||||||
function ReadItem(RegValue: Integer): TQueryHistoryItem;
|
function ReadItem(RegValue: String): TQueryHistoryItem;
|
||||||
end;
|
end;
|
||||||
TQueryHistoryItemComparer = class(TComparer<TQueryHistoryItem>)
|
TQueryHistoryItemComparer = class(TComparer<TQueryHistoryItem>)
|
||||||
function Compare(const Left, Right: TQueryHistoryItem): Integer; override;
|
function Compare(const Left, Right: TQueryHistoryItem): Integer; override;
|
||||||
@ -2469,7 +2469,7 @@ begin
|
|||||||
MainReg.GetValueNames(AllRegItems);
|
MainReg.GetValueNames(AllRegItems);
|
||||||
History := TQueryHistory.Create;
|
History := TQueryHistory.Create;
|
||||||
for RegItem in AllRegItems do begin
|
for RegItem in AllRegItems do begin
|
||||||
History.ReadItem(StrToInt(RegItem));
|
History.ReadItem(RegItem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Find lowest unused item number
|
// Find lowest unused item number
|
||||||
@ -10365,7 +10365,7 @@ begin
|
|||||||
MainReg.GetValueNames(Values);
|
MainReg.GetValueNames(Values);
|
||||||
History := TQueryHistory.Create;
|
History := TQueryHistory.Create;
|
||||||
for v in Values do begin
|
for v in Values do begin
|
||||||
Item := History.ReadItem(StrToInt(v));
|
Item := History.ReadItem(v);
|
||||||
QueryDay := DateToStr(Item.Time);
|
QueryDay := DateToStr(Item.Time);
|
||||||
if Tab.HistoryDays.IndexOf(QueryDay) = -1 then
|
if Tab.HistoryDays.IndexOf(QueryDay) = -1 then
|
||||||
Tab.HistoryDays.Add(QueryDay);
|
Tab.HistoryDays.Add(QueryDay);
|
||||||
@ -10387,7 +10387,7 @@ begin
|
|||||||
Values := TStringList.Create;
|
Values := TStringList.Create;
|
||||||
MainReg.GetValueNames(Values);
|
MainReg.GetValueNames(Values);
|
||||||
for v in Values do begin
|
for v in Values do begin
|
||||||
Item := History.ReadItem(StrToInt(v));
|
Item := History.ReadItem(v);
|
||||||
QueryDay := DateToStr(Item.Time);
|
QueryDay := DateToStr(Item.Time);
|
||||||
if QueryDay <> Tab.HistoryDays[Node.Index] then
|
if QueryDay <> Tab.HistoryDays[Node.Index] then
|
||||||
History.Remove(Item);
|
History.Remove(Item);
|
||||||
@ -10857,14 +10857,20 @@ end;
|
|||||||
|
|
||||||
{ TQueryHistory }
|
{ TQueryHistory }
|
||||||
|
|
||||||
function TQueryHistory.ReadItem(RegValue: Integer): TQueryHistoryItem;
|
function TQueryHistory.ReadItem(RegValue: String): TQueryHistoryItem;
|
||||||
var
|
var
|
||||||
p: Integer;
|
i, p: Integer;
|
||||||
Raw: String;
|
Raw: String;
|
||||||
begin
|
begin
|
||||||
|
i := StrToIntDef(RegValue, -1);
|
||||||
|
// Prevent from running into serious errors when registry has some non-numeric value
|
||||||
|
if i=-1 then begin
|
||||||
|
Result := nil;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
Result := TQueryHistoryItem.Create;
|
Result := TQueryHistoryItem.Create;
|
||||||
Result.RegValue := RegValue;
|
Result.RegValue := i;
|
||||||
Raw := MainReg.ReadString(IntToStr(RegValue));
|
Raw := MainReg.ReadString(RegValue);
|
||||||
p := Pos(DELIM, Raw);
|
p := Pos(DELIM, Raw);
|
||||||
Result.Time := StrToDateTime(Copy(Raw, 1, p-1));
|
Result.Time := StrToDateTime(Copy(Raw, 1, p-1));
|
||||||
System.Delete(Raw, 1, p);
|
System.Delete(Raw, 1, p);
|
||||||
|
Reference in New Issue
Block a user