Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Delphi_str_2xFree_Minimized;
- {$APPTYPE CONSOLE}
- (************************
- Delphi Classic compilers bug demonstration: LongString double-free.
- Discovered: Arioch on Delphi XE2 Win32
- Minimized: nicholaos @ http://www.sql.ru/forum/actualutils.aspx?action=gotomsg&tid=1300873&msg=21640617
- Tested by nicholoas: Embarcadero® Delphi 10.2 Version 25.0.26309.314, Win32 & Win64
- Reportedly fails with "Illegal Pointer Operator".
- Tested by Arioch on XE2 - does not trigger strings de-alloc bug, fails with proper "file not found".
- ************************)
- uses
- IOUtils, SysUtils;
- var
- VolatileFN: string;
- procedure Test(const ConstFN: string); // Hulk crash!
- begin
- VolatileFN := Copy(ConstFN, 1, 12);
- TFile.ReadAllText(ConstFN);
- end;
- begin
- try
- try
- VolatileFN := 'c:\Windows\win.ini';
- Test(VolatileFN);
- Writeln('Finished w/o Illegal Pointer Operation');
- except
- on E: Exception do
- Writeln(E.ClassName, ': ', E.Message);
- end;
- finally
- Writeln;
- Writeln('Read the output. Press ENTER to terminate the program.');
- Readln;
- end;
- end.
Add Comment
Please, Sign In to add comment