Pārlūkot izejas kodu

* dereference pchar passed to indexbyte in strecopy (patch by Andrew Haines,
mantis #21443)

git-svn-id: trunk@20481 -

Jonas Maebe 13 gadi atpakaļ
vecāks
revīzija
3ebdd64d75
3 mainītis faili ar 22 papildinājumiem un 1 dzēšanām
  1. 1 0
      .gitattributes
  2. 1 1
      rtl/inc/genstr.inc
  3. 20 0
      tests/webtbs/tw21443.pp

+ 1 - 0
.gitattributes

@@ -12237,6 +12237,7 @@ tests/webtbs/tw2128.pp svneol=native#text/plain
 tests/webtbs/tw2129.pp svneol=native#text/plain
 tests/webtbs/tw2129b.pp svneol=native#text/plain
 tests/webtbs/tw2131.pp svneol=native#text/plain
+tests/webtbs/tw21443.pp svneol=native#text/plain
 tests/webtbs/tw2145.pp svneol=native#text/plain
 tests/webtbs/tw2158.pp svneol=native#text/plain
 tests/webtbs/tw2159.pp svneol=native#text/plain

+ 1 - 1
rtl/inc/genstr.inc

@@ -203,7 +203,7 @@
  var
    counter : SizeInt;
  Begin
-   counter := IndexByte(Source,-1,0);
+   counter := IndexByte(Source^,-1,0);
    { counter+1 will move zero terminator }
    Move(Source^,Dest^,counter+1);
    StrECopy := Dest+counter;

+ 20 - 0
tests/webtbs/tw21443.pp

@@ -0,0 +1,20 @@
+uses
+  strings;
+
+var
+  p1, p2, p3, p4: pchar;
+begin
+
+ { StrECopy(Dest,Source) is equivalent to the following:
+    strcopy(Dest,Source);
+    StrECopy := StrEnd(Dest);
+  }
+  p1:='abcdefg';
+  getmem(p2,100);
+  p3:=strecopy(p2,p1);
+  fillchar(p2^,100,0);
+  strcopy(p2,p1);
+  p4:=strend(p2);
+  if p3<>p4 then
+    halt(1);
+end.