chakra-core / ChakraCore

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

Module api bugs #6992

Closed rhuanjl closed 6 months ago

rhuanjl commented 6 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