chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.1k stars 1.19k forks source link

Module api bugs #6992

Closed rhuanjl closed 4 months ago

rhuanjl commented 5 months ago

These two small bugs have been knocking around for a while; both relate to incorrect/unintended use of the hosting APIs but they both can lead to nullptr de-refs rather than returning error codes as an embedder should expect.

  1. When a module was imported from a script triggerring the fetchImportedModuleFromScriptCallback, CC was incorrectly checking if the fetchImportedModuledCallback was set but not checking the callback it was actually going to use. (I did a minor refactor fixing this, eliminating a helper method as whilst this meant some small code duplication it was a net 0 change to total lines of code, gained lines are fix number 2 and copyright changes)
  2. When GetModuleNumespace was invked on a module marked as evaluated BUT having a syntax error, CC was performing a nullptr de-ref rather than returning an error code.

FYI @fatcerberus

Fix: #5880 Fix: #6788