Fix potential integer overflow issues (#4429)
It is reported as "Multiplication result converted to larger type". And "Multiplication result may overflow 'Type A' before it is converted to 'Type B'." Type A is a larger type than Type B. Since the conversion applies after the multiplication, arithmetic overflow may still occur. > The rule flags every multiplication of two non-constant integer expressions > that is (explicitly or implicitly) converted to a larger integer type. The > conversion is an indication that the expression would produce a result that > would be too large to fit in the smaller integer type.
This commit is contained in:
@ -347,7 +347,8 @@ call_aot_invoke_c_api_native(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
|
||||
/* Get &c_api_func_imports[func_idx], note size of CApiFuncImport
|
||||
is pointer_size * 3 */
|
||||
offset = I32_CONST((comp_ctx->pointer_size * 3) * import_func_idx);
|
||||
offset = I32_CONST((unsigned long long)comp_ctx->pointer_size * 3
|
||||
* import_func_idx);
|
||||
CHECK_LLVM_CONST(offset);
|
||||
c_api_func_import =
|
||||
LLVMBuildInBoundsGEP2(comp_ctx->builder, INT8_TYPE, c_api_func_imports,
|
||||
|
||||
Reference in New Issue
Block a user