comobj: for loop to ArgCount - 1 causes a crash when ArgCount = 0 because it is unsigned

git-svn-id: trunk@14743 -
This commit is contained in:
paul 2010-01-19 07:16:37 +00:00
parent 75e702c2e8
commit 9f7a69627a

View File

@ -1346,29 +1346,30 @@ HKCR
GetMem(Arguments,desc^.calldesc.argcount*sizeof(TVarData)); GetMem(Arguments,desc^.calldesc.argcount*sizeof(TVarData));
{ prepare parameters } { prepare parameters }
if desc^.CallDesc.ArgCount > 0 then
for i:=0 to desc^.CallDesc.ArgCount-1 do for i:=0 to desc^.CallDesc.ArgCount-1 do
begin begin
{$ifdef DEBUG_DISPATCH} {$ifdef DEBUG_DISPATCH}
writeln('DoDispCallByID: Params = ',hexstr(PtrInt(Params),SizeOf(Pointer)*2)); writeln('DoDispCallByID: Params = ',hexstr(PtrInt(Params),SizeOf(Pointer)*2));
{$endif DEBUG_DISPATCH} {$endif DEBUG_DISPATCH}
{ get plain type } { get plain type }
CurrType:=desc^.CallDesc.ArgTypes[i] and $3f; CurrType:=desc^.CallDesc.ArgTypes[i] and $3f;
{ by reference? } { by reference? }
if (desc^.CallDesc.ArgTypes[i] and $80)<>0 then if (desc^.CallDesc.ArgTypes[i] and $80)<>0 then
begin begin
{$ifdef DEBUG_DISPATCH} {$ifdef DEBUG_DISPATCH}
write('DispatchInvoke: Got ref argument with type = ',CurrType); write('DispatchInvoke: Got ref argument with type = ',CurrType);
writeln; writeln;
{$endif DEBUG_DISPATCH} {$endif DEBUG_DISPATCH}
Arguments[i].VType:=CurrType or VarByRef; Arguments[i].VType:=CurrType or VarByRef;
Arguments[i].VPointer:=PPointer(Params)^; Arguments[i].VPointer:=PPointer(Params)^;
inc(PPointer(Params)); inc(PPointer(Params));
end end
else else
begin begin
{$ifdef DEBUG_DISPATCH} {$ifdef DEBUG_DISPATCH}
writeln('DispatchInvoke: Got ref argument with type = ',CurrType); writeln('DispatchInvoke: Got ref argument with type = ',CurrType);
{$endif DEBUG_DISPATCH} {$endif DEBUG_DISPATCH}
case CurrType of case CurrType of
varVariant: varVariant:
begin begin
@ -1380,18 +1381,18 @@ HKCR
varDouble, varDouble,
VarDate: VarDate:
begin begin
{$ifdef DEBUG_DISPATCH} {$ifdef DEBUG_DISPATCH}
writeln('DispatchInvoke: Got 8 byte float argument'); writeln('DispatchInvoke: Got 8 byte float argument');
{$endif DEBUG_DISPATCH} {$endif DEBUG_DISPATCH}
Arguments[i].VType:=CurrType; Arguments[i].VType:=CurrType;
move(PPointer(Params)^,Arguments[i].VDouble,sizeof(Double)); move(PPointer(Params)^,Arguments[i].VDouble,sizeof(Double));
inc(PDouble(Params)); inc(PDouble(Params));
end; end;
else else
begin begin
{$ifdef DEBUG_DISPATCH} {$ifdef DEBUG_DISPATCH}
writeln('DispatchInvoke: Got argument with type ',CurrType); writeln('DispatchInvoke: Got argument with type ',CurrType);
{$endif DEBUG_DISPATCH} {$endif DEBUG_DISPATCH}
Arguments[i].VType:=CurrType; Arguments[i].VType:=CurrType;
Arguments[i].VPointer:=PPointer(Params)^; Arguments[i].VPointer:=PPointer(Params)^;
inc(PPointer(Params)); inc(PPointer(Params));