mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 18:39:19 +02:00
* Explicitly increment and decrement ref count to keep copy of destination string in fpc_AnsiStr_Concat_multi and fpc_WideStr_Concat_multi. It prevents note "Local variable "destcopy" is assigned but never used".
git-svn-id: trunk@9554 -
This commit is contained in:
parent
eadfbb5027
commit
cd03a2893b
@ -250,13 +250,14 @@ Var
|
|||||||
p,pc : pointer;
|
p,pc : pointer;
|
||||||
Size,NewLen,
|
Size,NewLen,
|
||||||
OldDestLen : SizeInt;
|
OldDestLen : SizeInt;
|
||||||
destcopy : ansistring;
|
destcopy : pointer;
|
||||||
begin
|
begin
|
||||||
if high(sarr)=0 then
|
if high(sarr)=0 then
|
||||||
begin
|
begin
|
||||||
DestS:='';
|
DestS:='';
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
destcopy:=nil;
|
||||||
lowstart:=low(sarr);
|
lowstart:=low(sarr);
|
||||||
if Pointer(DestS)=Pointer(sarr[lowstart]) then
|
if Pointer(DestS)=Pointer(sarr[lowstart]) then
|
||||||
inc(lowstart);
|
inc(lowstart);
|
||||||
@ -269,7 +270,8 @@ begin
|
|||||||
{ if DestS is used somewhere in the middle of the expression,
|
{ if DestS is used somewhere in the middle of the expression,
|
||||||
we need to make sure the original string still exists after
|
we need to make sure the original string still exists after
|
||||||
we empty/modify DestS }
|
we empty/modify DestS }
|
||||||
destcopy:=dests;
|
destcopy:=pointer(dests);
|
||||||
|
fpc_AnsiStr_Incr_Ref(destcopy);
|
||||||
lowstart:=low(sarr);
|
lowstart:=low(sarr);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
@ -298,6 +300,7 @@ begin
|
|||||||
inc(pc,size);
|
inc(pc,size);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
fpc_AnsiStr_Decr_Ref(destcopy);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -578,13 +578,14 @@ Var
|
|||||||
p,pc : pointer;
|
p,pc : pointer;
|
||||||
Size,NewLen,
|
Size,NewLen,
|
||||||
OldDestLen : SizeInt;
|
OldDestLen : SizeInt;
|
||||||
destcopy : widestring;
|
destcopy : pointer;
|
||||||
begin
|
begin
|
||||||
if high(sarr)=0 then
|
if high(sarr)=0 then
|
||||||
begin
|
begin
|
||||||
DestS:='';
|
DestS:='';
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
destcopy:=nil;
|
||||||
lowstart:=low(sarr);
|
lowstart:=low(sarr);
|
||||||
if Pointer(DestS)=Pointer(sarr[lowstart]) then
|
if Pointer(DestS)=Pointer(sarr[lowstart]) then
|
||||||
inc(lowstart);
|
inc(lowstart);
|
||||||
@ -597,7 +598,8 @@ begin
|
|||||||
{ if DestS is used somewhere in the middle of the expression,
|
{ if DestS is used somewhere in the middle of the expression,
|
||||||
we need to make sure the original string still exists after
|
we need to make sure the original string still exists after
|
||||||
we empty/modify DestS }
|
we empty/modify DestS }
|
||||||
destcopy:=dests;
|
destcopy:=pointer(dests);
|
||||||
|
fpc_WideStr_Incr_Ref(destcopy);
|
||||||
lowstart:=low(sarr);
|
lowstart:=low(sarr);
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
@ -626,6 +628,7 @@ begin
|
|||||||
inc(pc,size*sizeof(WideChar));
|
inc(pc,size*sizeof(WideChar));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
fpc_WideStr_Decr_Ref(destcopy);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$endif STR_CONCAT_PROCS}
|
{$endif STR_CONCAT_PROCS}
|
||||||
|
Loading…
Reference in New Issue
Block a user