From 2865826fc45e81ffaa74573a0f5e60a0b89bd079 Mon Sep 17 00:00:00 2001 From: Zidong Jiang Date: Fri, 10 Nov 2017 13:11:26 +0100 Subject: [PATCH] [jerryx-module]Fix a bug in module name comparison (#2079) JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com --- jerry-ext/module/module.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jerry-ext/module/module.c b/jerry-ext/module/module.c index 30e75ede1..4cdde0275 100644 --- a/jerry-ext/module/module.c +++ b/jerry-ext/module/module.c @@ -179,7 +179,9 @@ jerryx_resolve_native_module (const jerry_value_t canonical_name, /**< canonical /* Look for the module by its name in the list of module definitions. */ for (module_p = first_module_p; module_p != NULL; module_p = module_p->next_p) { - if (module_p->name_p != NULL && !strncmp ((char *) module_p->name_p, (char *) name_string, name_size)) + if (module_p->name_p != NULL + && strlen ((char *) module_p->name_p) == name_size + && !strncmp ((char *) module_p->name_p, (char *) name_string, name_size)) { /* If we find the module by its name we load it and cache it if it has an on_resolve () and complain otherwise. */ (*result) = ((module_p->on_resolve_p) ? module_p->on_resolve_p ()