Skip to content

Commit

Permalink
[crt] fix shift out of type bounds (apache#7733)
Browse files Browse the repository at this point in the history
* [crt] fix shift out of type bounds
  • Loading branch information
rafzi authored and Trevor Morris committed May 6, 2021
1 parent cb1252b commit 22c82c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/runtime/crt/common/crt_runtime_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ int SystemLibraryCreate(TVMValue* args, int* type_codes, int num_args, TVMValue*

static TVMFunctionHandle EncodeFunctionHandle(tvm_module_index_t module_index,
tvm_function_index_t function_index) {
return (TVMFunctionHandle)((uintptr_t)(
((module_index | 0x8000) << (sizeof(tvm_function_index_t) * 8)) | (function_index | 0x8000)));
return (TVMFunctionHandle)(
(((uintptr_t)(module_index | 0x8000) << (sizeof(tvm_function_index_t) * 8)) |
(function_index | 0x8000)));
}

static int DecodeFunctionHandle(TVMFunctionHandle handle, tvm_module_index_t* module_index,
Expand Down Expand Up @@ -365,7 +366,7 @@ int TVMCFuncSetReturn(TVMRetValueHandle ret, TVMValue* value, int* type_code, in
}

int TVMFuncFree(TVMFunctionHandle func) {
// A no-op, since we don't actually allocate anything in GetFunction
// A no-op, since we don't actually allocate anything in GetFunction.
return 0;
}

Expand Down

0 comments on commit 22c82c5

Please sign in to comment.