Skip to content

Commit 8471ddd

Browse files
GregoryComerfacebook-github-bot
authored andcommitted
Check for null method in module execute
Summary: This is an attempt to partially mitigate use after free crashes when a module is unloaded during inference. This is not a supported use pattern, but it doesn't to sanity check here to avoid a crash. Differential Revision: D71968421
1 parent 976fe48 commit 8471ddd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

extension/module/module.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ runtime::Result<std::vector<runtime::EValue>> Module::execute(
236236
ET_CHECK_OK_OR_RETURN_ERROR(load_method(method_name));
237237
auto& method = methods_.at(method_name).method;
238238
auto& inputs = methods_.at(method_name).inputs;
239+
240+
ET_CHECK_OR_RETURN_ERROR(method != nullptr, InvalidArgument, "Method is null");
239241

240242
for (size_t i = 0; i < input_values.size(); ++i) {
241243
if (!input_values[i].isNone()) {

0 commit comments

Comments
 (0)