Skip to content

[Patch] StreamIO crashes in Close()

Summary

Closing a file used with StreamIO crashes

System Information

  • Operating system: macOS Ventura 13.6
  • Processor architecture: x86-64
  • Compiler version: trunk 1e64126f
  • Device: computer

Steps to reproduce

Run test-case:

program TestStreamIOCrash;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes,
  streamIO;

var
  ms: TMemoryStream;
  F: TextFile;
begin
  ms:= TMemoryStream.Create;
  try
    FillChar(F, SizeOf(F), $80); //make sure this crashes
    AssignStream(F, ms);
    Rewrite(F);
    try
      Write(F, 'Close will crash');
    finally
      Close(F);
    end;
  finally
    ms.Free;
  end;
end.

What is the current bug behavior?

Crashes in Close()

What is the expected (correct) behavior?

Should not crash.

Possible fixes

AssignStream must initialise "new" TextRec.FullName string.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information