summaryrefslogtreecommitdiff
path: root/src/binary-reader.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary-reader.cc')
-rw-r--r--src/binary-reader.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index 4ac9c746..136b4c4a 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -943,6 +943,8 @@ static void read_custom_section(Context* ctx, uint32_t section_size) {
StringSlice function_name;
in_u32_leb128(ctx, &function_index, "function index");
+ RAISE_ERROR_UNLESS(function_index < num_total_funcs(ctx),
+ "invalid function index: %u", function_index);
in_str(ctx, &function_name, "function name");
CALLBACK(OnFunctionName, function_index, function_name);
}