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