* fixed inserting something in a shortstring past its maximum length

(mantis #23744)

git-svn-id: trunk@23524 -
This commit is contained in:
Jonas Maebe 2013-01-26 19:27:17 +00:00
parent 2ed4b295fe
commit a8a1bb6449
3 changed files with 26 additions and 2 deletions

1
.gitattributes vendored
View File

@ -13155,6 +13155,7 @@ tests/webtbs/tw23486.pp svneol=native#text/pascal
tests/webtbs/tw23503.pp svneol=native#text/pascal
tests/webtbs/tw2351.pp svneol=native#text/plain
tests/webtbs/tw2363.pp svneol=native#text/plain
tests/webtbs/tw23744.pp svneol=native#text/plain
tests/webtbs/tw2377.pp svneol=native#text/plain
tests/webtbs/tw2378.pp svneol=native#text/plain
tests/webtbs/tw2382.pp svneol=native#text/plain

View File

@ -74,7 +74,11 @@ begin
if index<1 then
index:=1;
if index>length(s) then
index:=length(s)+1;
begin
index:=length(s)+1;
if index>high(s) then
exit;
end;
indexlen:=Length(s)-Index+1;
srclen:=length(Source);
if sizeInt(length(source))+sizeint(length(s))>=sizeof(s) then
@ -104,7 +108,11 @@ begin
if index<1 then
index:=1;
if index>length(s) then
index:=length(s)+1;
begin
index:=length(s)+1;
if index>high(s) then
exit;
end;
indexlen:=Length(s)-Index+1;
if (sizeint(length(s))+1=sizeof(s)) and (indexlen>0) then
dec(indexlen);

15
tests/webtbs/tw23744.pp Normal file
View File

@ -0,0 +1,15 @@
var
S:String[16];
C:Char = '?';
inss: string = 'abc';
begin
S:='DefineTestString';
Insert(C,S,20);
if (length(s)>16) or
(s<>'DefineTestString') then
halt(1);
insert(inss,s,20);
if (length(s)>16) or
(s<>'DefineTestString') then
halt(2);
end.