From ee5b3ce326df807456c480ef39d9dc04e454f293 Mon Sep 17 00:00:00 2001 From: Volker Berlin Date: Sat, 2 May 2020 15:31:26 +0200 Subject: [PATCH] only set a function index if method is used --- src/de/inetsoftware/jwebassembly/module/TypeManager.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/TypeManager.java b/src/de/inetsoftware/jwebassembly/module/TypeManager.java index a39498b..6c68a2f 100644 --- a/src/de/inetsoftware/jwebassembly/module/TypeManager.java +++ b/src/de/inetsoftware/jwebassembly/module/TypeManager.java @@ -494,7 +494,9 @@ public class TypeManager { // if a new needed method then add it methods.add( funcName ); } - functions.setFunctionIndex( funcName, idx + VTABLE_FIRST_FUNCTION_INDEX ); + if( idx < methods.size() ) { + functions.setFunctionIndex( funcName, idx + VTABLE_FIRST_FUNCTION_INDEX ); + } } } @@ -564,7 +566,10 @@ public class TypeManager { * @param getFunctionsID * source for function IDs * @throws IOException - * should never occur + * should never occur + * @see TypeManager#TYPE_DESCRIPTION_INTERFACE_OFFSET + * @see TypeManager#TYPE_DESCRIPTION_INSTANCEOF_OFFSET + * @see TypeManager#TYPE_DESCRIPTION_TYPE_NAME */ public void writeToStream( ByteArrayOutputStream dataStream, ToIntFunction getFunctionsID ) throws IOException { /*