<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Strange fpstat adds #0, so it should
      never be nil.<br>
      <br>
      But valgrind said it was <br>
      <br>
      On 04/10/2026 11:08, Martin Frb via fpc-devel wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:266bea14-cbe9-4d00-896f-06cdc57c20f4@mfriebe.de">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      Are older Linux versions safe to  call stat with a nil pointer?<br>
      <br>
      <a class="moz-txt-link-freetext"
        href="https://man7.org/linux/man-pages/man2/stat.2.html"
        moz-do-not-send="true">https://man7.org/linux/man-pages/man2/stat.2.html</a><br>
      >  If <i>path</i> is an empty string (or NULL, since Linux
      6.11)<br>
      <br>
      (According to google 6.11 is from 2024 / if so, older versions are
      still out there)<br>
      <br>
      <br>
      <br>
      3.3.1\source\rtl\unix\sysutils.pp<br>
      <br>
      Function DirectoryExists (Const Directory : RawByteString;
      FollowLink : Boolean) : Boolean;<br>
      Var<br>
        Info : Stat;<br>
        SystemFileName: RawByteString;<br>
        exists: Boolean;<br>
      begin<br>
       
      SystemFileName:=ToSingleByteFileSystemEncodedFileName(Directory);<br>
        exists:=fpstat(pointer(SystemFileName),Info)>=0;<br>
      <br>
      <br>
      If the filename is empty, then path is nil.<br>
      <br>
      Valgrind annotates that (even on a new Linux)<br>
      ==28712== Syscall param stat(file_name) points to unaddressable
      byte(s)<br>
      ==28712==    at 0x4B2B64:
      SYSTEM_$$_FPSYSCALL$INT64$INT64$INT64$$INT64 (in
      /home/me/lazgit/lazarus)<br>
      ==28712==    by 0x4B3884: SYSTEM_$$_FPSTAT$PCHAR$STAT$$LONGINT (in
      /home/me/lazgit/lazarus)<br>
      ==28712==  Address 0x0 is not stack'd, malloc'd or (recently)
      free'd<br>
      <br>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre wrap="" class="moz-quote-pre">_______________________________________________
fpc-devel maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>