mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 21:11:23 +02:00
* fixed StrPLCopy() with maxlen=0 (mantis #28089, patch by LacaK)
git-svn-id: trunk@30858 -
This commit is contained in:
parent
ac592ed634
commit
afd5ed4afe
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -14487,6 +14487,7 @@ tests/webtbs/tw28007.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2803.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2806.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2807.pp svneol=native#text/plain
|
||||
tests/webtbs/tw28089.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2809.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2812.pp svneol=native#text/plain
|
||||
tests/webtbs/tw2815.pp svneol=native#text/plain
|
||||
|
@ -78,18 +78,17 @@ end ;
|
||||
function StrPLCopy(Dest: PChar; Const Source: string; MaxLen: SizeUInt): PChar;overload;
|
||||
var Count: SizeUInt;
|
||||
begin
|
||||
result := Dest;
|
||||
if (Result <> Nil) and (MaxLen <> 0) then
|
||||
Result := Dest;
|
||||
if Result <> Nil then
|
||||
begin
|
||||
Count := Length(Source);
|
||||
if Count > MaxLen then
|
||||
Count := MaxLen;
|
||||
StrMove(Dest, PChar(Source), Count);
|
||||
result[Count] := #0; { terminate ! }
|
||||
StrMove(Result, PChar(Source), Count);
|
||||
Result[Count] := #0; { terminate ! }
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
{ StrDispose clears the memory allocated with StrAlloc }
|
||||
|
||||
procedure StrDispose(Str: PChar);
|
||||
|
17
tests/webtbs/tw28089.pp
Normal file
17
tests/webtbs/tw28089.pp
Normal file
@ -0,0 +1,17 @@
|
||||
program bug_StrPLCopy;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
var
|
||||
Buf: array[0..10] of Char;
|
||||
|
||||
begin
|
||||
Buf[0] := 'A';
|
||||
writeln(ord(Buf[0]));
|
||||
StrPLCopy(Buf, '', 0);
|
||||
writeln(ord(Buf[0]));
|
||||
readln;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user