diff --git a/js/xpconnect/src/XPCQuickStubs.h b/js/xpconnect/src/XPCQuickStubs.h index dd431a043858..2086cb1c9fd3 100644 --- a/js/xpconnect/src/XPCQuickStubs.h +++ b/js/xpconnect/src/XPCQuickStubs.h @@ -49,7 +49,7 @@ class XPCCallContext; -#define XPC_QS_NULL_INDEX ((size_t) -1) +#define XPC_QS_NULL_INDEX ((uint16_t) -1) struct xpc_qsPropertySpec { const char *name; @@ -76,8 +76,8 @@ struct xpc_qsHashEntry { const xpc_qsFunctionSpec *functions; // These last two fields index to other entries in the same table. // XPC_QS_NULL_ENTRY indicates there are no more entries in the chain. - size_t parentInterface; - size_t chain; + uint16_t parentInterface; + uint16_t chain; }; inline nsISupports* diff --git a/js/xpconnect/src/qsgen.py b/js/xpconnect/src/qsgen.py index a0592e980d86..f711a6f014e8 100644 --- a/js/xpconnect/src/qsgen.py +++ b/js/xpconnect/src/qsgen.py @@ -1235,6 +1235,9 @@ def writeDefiner(f, conf, interfaces): f.write("static const xpc_qsHashEntry tableData[] = {\n") f.write(",\n".join(entries)) f.write("\n };\n\n") + f.write("// Make sure our table indices aren't overflowed\n" + "PR_STATIC_ASSERT((sizeof(tableData) / sizeof(tableData[0])) < (1 << (8 * sizeof(tableData[0].parentInterface))));\n" + "PR_STATIC_ASSERT((sizeof(tableData) / sizeof(tableData[0])) < (1 << (8 * sizeof(tableData[0].chain))));\n\n") # the definer function (entry point to this quick stubs file) f.write("JSBool %s_DefineQuickStubs(" % conf.name)