Skip to content

Commit

Permalink
Pass proper fixed argument count
Browse files Browse the repository at this point in the history
The fixedParameterTypes array will be one wider than the count of
fixed arguments, since the final argument will be a Java vararg.
  • Loading branch information
headius committed Jan 5, 2022
1 parent b5c1708 commit e0bcc35
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ public final Object invoke(Object self, Object[] parameters) {
variableArgs[variableArgsCount] = null;
variableArgsCount++;

int totalArgsCount = variableArgsCount + fixedParameterTypes.length - 1;
int fixedParamCount = fixedParameterTypes.length - 1;
int totalArgsCount = variableArgsCount + fixedParamCount;
Function function = new Function(functionAddress,
getCallContext(resultType, fixedParameterTypes.length, argTypes, totalArgsCount, callingConvention, requiresErrno));
getCallContext(resultType, fixedParamCount, argTypes, totalArgsCount, callingConvention, requiresErrno));
HeapInvocationBuffer buffer = new HeapInvocationBuffer(function.getCallContext());

InvocationSession session = new InvocationSession();
Expand All @@ -380,7 +381,7 @@ public final Object invoke(Object self, Object[] parameters) {
}

for (int i = 0; i < variableArgsCount; ++i) {
getMarshaller(argTypes[i + fixedParameterTypes.length - 1]).marshal(session, buffer, variableArgs[i]);
getMarshaller(argTypes[i + fixedParamCount]).marshal(session, buffer, variableArgs[i]);
}

return functionInvoker.invoke(runtime, function, buffer);
Expand Down

0 comments on commit e0bcc35

Please sign in to comment.