Browse Source

--- Merging r22969 into '.':
U rtl/unix/cwstring.pp
--- Merging r22992 into '.':
U rtl/objpas/classes/stringl.inc
--- Merging r23000 into '.':
U rtl/objpas/objpas.pp

# revisions: 22969,22992,23000
r22969 | jonas | 2012-11-10 21:26:46 +0100 (Sat, 10 Nov 2012) | 2 lines
Changed paths:
M /trunk/rtl/unix/cwstring.pp

* fixed compatilation on Haiku Alpha4 (patch by Olivier Coursi?\195?\168re,
mantis #23300)
r22992 | michael | 2012-11-16 12:04:44 +0100 (Fri, 16 Nov 2012) | 1 line
Changed paths:
M /trunk/rtl/objpas/classes/stringl.inc

* Prevent Move from freeing an associated object if OwnsObjects=True (reported on sourceforge)
r23000 | sergei | 2012-11-16 19:27:55 +0100 (Fri, 16 Nov 2012) | 2 lines
Changed paths:
M /trunk/rtl/objpas/objpas.pp

* Ansistring versions of MkDir,ChDir,RmDir: make a full copy of argument string. This is necessary because underlying implementations can modify directory separators in argument, causing crash if argument resides in read-only memory. This is also consistent with shortstring variants of same procedures.

git-svn-id: branches/fixes_2_6@24955 -

marco 12 years ago
parent
commit
a8181ce5b2
3 changed files with 14 additions and 8 deletions
  1. 1 0
      rtl/objpas/classes/stringl.inc
  2. 12 6
      rtl/objpas/objpas.pp
  3. 1 2
      rtl/unix/cwstring.pp

+ 1 - 0
rtl/objpas/classes/stringl.inc

@@ -868,6 +868,7 @@ begin
   BeginUpdate;
   Obj:=Objects[CurIndex];
   Str:=Strings[CurIndex];
+  Objects[CurIndex]:=Nil; // Prevent Delete from freeing.
   Delete(Curindex);
   InsertObject(NewIndex,Str,Obj);
   EndUpdate;

+ 12 - 6
rtl/objpas/objpas.pp

@@ -92,9 +92,9 @@ Var
 {$endif FPC_HAS_FEATURE_COMMANDARGS}
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-     Procedure MkDir(const s:ansistring);overload;
-     Procedure RmDir(const s:ansistring);overload;
-     Procedure ChDir(const s:ansistring);overload;
+     Procedure MkDir(s:ansistring);overload;
+     Procedure RmDir(s:ansistring);overload;
+     Procedure ChDir(s:ansistring);overload;
 {$endif FPC_HAS_FEATURE_FILEIO}
 
 {****************************************************************************
@@ -249,18 +249,24 @@ end;
 
 
 {$ifdef FPC_HAS_FEATURE_FILEIO}
-Procedure MkDir(const s:ansistring);[IOCheck];
+{ xxDirPChar procedures can adjust directory separators in supplied string (at least
+  Windows implementation does so). Therefore full copy of argument is needed,
+  just passing by value isn't enough because it won't copy a string literal. }
+Procedure MkDir(s:ansistring);[IOCheck];
 begin
+  UniqueString(s);
   mkdirpchar(pchar(s),length(s));
 end;
 
-Procedure RmDir(const s:ansistring);[IOCheck];
+Procedure RmDir(s:ansistring);[IOCheck];
 begin
+  UniqueString(s);
   RmDirpchar(pchar(s),length(s));
 end;
 
-Procedure ChDir(const s:ansistring);[IOCheck];
+Procedure ChDir(s:ansistring);[IOCheck];
 begin
+  UniqueString(s);
   ChDirpchar(pchar(s),length(s));
 end;
 {$endif FPC_HAS_FEATURE_FILEIO}

+ 1 - 2
rtl/unix/cwstring.pp

@@ -40,7 +40,6 @@ implementation
 {$ifndef iconv_is_in_libc}
  {$if defined(haiku)}
    {$linklib textencoding}
-   {$linklib locale}
  {$else}
    {$linklib iconv}
  {$endif}
@@ -162,7 +161,7 @@ type
   nl_item = cint;
 
 {$ifdef haiku}
-  function nl_langinfo(__item:nl_item):pchar;cdecl;external 'locale' name 'nl_langinfo';
+  function nl_langinfo(__item:nl_item):pchar;cdecl;external 'root' name 'nl_langinfo';
 {$else}
   {$ifndef beos}
   function nl_langinfo(__item:nl_item):pchar;cdecl;external libiconvname name 'nl_langinfo';