🚨 Guard location name serialization against empty strings
Saving or loading an unnamed location indexed the first character of an empty string.
This commit is contained in:
@@ -1977,8 +1977,12 @@ begin
|
|||||||
Stream.Read(locationInfo^.Y, SizeOf(Word));
|
Stream.Read(locationInfo^.Y, SizeOf(Word));
|
||||||
stringLength := 0;
|
stringLength := 0;
|
||||||
Stream.Read(stringLength, SizeOf(Integer));
|
Stream.Read(stringLength, SizeOf(Integer));
|
||||||
|
if stringLength > 0 then
|
||||||
|
begin
|
||||||
SetLength(s, stringLength);
|
SetLength(s, stringLength);
|
||||||
Stream.Read(s[1], stringLength);
|
Stream.Read(s[1], stringLength);
|
||||||
|
end else
|
||||||
|
SetLength(s, 0);
|
||||||
locationInfo^.Name := s;
|
locationInfo^.Name := s;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -2005,6 +2009,7 @@ begin
|
|||||||
Stream.Write(locationInfo^.Y, SizeOf(Word));
|
Stream.Write(locationInfo^.Y, SizeOf(Word));
|
||||||
stringLength := Length(locationInfo^.Name);
|
stringLength := Length(locationInfo^.Name);
|
||||||
Stream.Write(stringLength, SizeOf(Integer));
|
Stream.Write(stringLength, SizeOf(Integer));
|
||||||
|
if stringLength > 0 then
|
||||||
Stream.Write(locationInfo^.Name[1], stringLength);
|
Stream.Write(locationInfo^.Name[1], stringLength);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user