summaryrefslogtreecommitdiff
path: root/src/binary-reader.cc
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-03-31 15:59:09 -0700
committerGitHub <noreply@github.com>2017-03-31 15:59:09 -0700
commitf57ff31c1425e5f066dd0959992fb2aabc39b510 (patch)
tree1a8b8356816ff96ebf3e9aba8867e0ac71f3b68e /src/binary-reader.cc
parentfeb6ee594bf670d5c637e8b11e598af2dc37f95d (diff)
downloadwabt-f57ff31c1425e5f066dd0959992fb2aabc39b510.tar.gz
wabt-f57ff31c1425e5f066dd0959992fb2aabc39b510.tar.bz2
wabt-f57ff31c1425e5f066dd0959992fb2aabc39b510.zip
Allow names section to be sparse (#381)
Only emit names for function that actually have one. Previously we were emitting empty strings for functions without names. The new version of the names section allow for a sparse list. Also, cleanup the function name handling in wasm-link.
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);
}