Skip to content

Commit 432fd72

Browse files
committed
No longer use the default namespace if the imported name length is zero, so a query using empty string instead.
1 parent 404697a commit 432fd72

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

lib/Runtime/Library/WebAssemblyInstance.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,14 @@ Var GetImportVariable(Wasm::WasmImport* wi, ScriptContext* ctx, Var ffi)
2222

2323
const char16* name = wi->importName;
2424
uint32 nameLen = wi->importNameLen;
25-
Var prop = nullptr;
26-
if (nameLen > 0)
27-
{
28-
PropertyRecord const * propertyRecord = nullptr;
29-
ctx->GetOrAddPropertyRecord(name, nameLen, &propertyRecord);
25+
PropertyRecord const * propertyRecord = nullptr;
26+
ctx->GetOrAddPropertyRecord(name, nameLen, &propertyRecord);
3027

31-
if (!RecyclableObject::Is(modProp))
32-
{
33-
JavascriptError::ThrowTypeError(ctx, WASMERR_InvalidImport);
34-
}
35-
prop = JavascriptOperators::OP_GetProperty(modProp, propertyRecord->GetPropertyId(), ctx);
36-
}
37-
else
28+
if (!RecyclableObject::Is(modProp))
3829
{
39-
// Use only first level if name is missing
40-
prop = modProp;
30+
JavascriptError::ThrowTypeError(ctx, WASMERR_InvalidImport);
4131
}
42-
43-
return prop;
32+
return JavascriptOperators::OP_GetProperty(modProp, propertyRecord->GetPropertyId(), ctx);
4433
}
4534

4635
WebAssemblyInstance::WebAssemblyInstance(WebAssemblyModule * wasmModule, DynamicType * type) :

test/wasm/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ const imports = {
1515
g1: 45,
1616
g2: -8,
1717
},
18-
table: new WebAssembly.Table({element: "anyfunc", initial: 30, maximum: 100})
18+
table: {"": new WebAssembly.Table({element: "anyfunc", initial: 30, maximum: 100})}
1919
};
2020

2121
function overrideImports(overrides) {
2222
return {
2323
test: Object.assign({}, imports.test, overrides),
24-
table: overrides.table || imports.table
24+
table: overrides.table ? {"":overrides.table} : imports.table
2525
};
2626
}
2727

0 commit comments

Comments
 (0)