Skip to content

makeConfigManagerWrapper() passes a possibly-NULL ConfigManager to the embedded-JS layer #676

Description

@JoeNemo

makeConfigManagerWrapper() returns a possibly-NULL ConfigManager into the embedded-JS layer.

Since #674, makeConfigManager() can return NULL. c/configmgr.c:1496 passes
the result straight out as a native pointer without testing it:

static void *makeConfigManagerWrapper(void *userData, EJSNativeInvocation *invocation){
  return makeConfigManager();
}

#674 updated simpleMain() and REXXCMGR() for the new contract but not this
one.

NULL is reachable without any z/OS state involvement. configureEmbeddedJS()
has a long-standing failure path -- JS_NewContext() returning null when the
runtime cannot allocate a context -- which frees its argument and returns false.
So this can occur on any platform, most likely when the system is already under
memory pressure.

Suggested: return NULL from the wrapper explicitly and let the JS binding raise,
rather than handing a null native pointer to freeConfigManagerWrapper() and
every method that follows.

Found while reviewing #674, which improves the surrounding code: before it, this
path stored the pointer configureEmbeddedJS() had just freed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions