Skip to content

Commit b08bd02

Browse files
committed
Fixed a regression when enumerable properties were added to Object.prototype
1 parent bfa79ae commit b08bd02

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
**This release is under development**
66

7+
- Fixed a regression when enumerable properties were added to
8+
`Object.prototype`.
9+
([#1129](https://github.com/oracle/node-oracledb/issues/1129)).
10+
711
- Fixed a regression with missing `metaData` from `connection.getStatementInfo()`
812

913
- Fixed passing DbObjects and JavaScript objects as the `payload` attribute for

src/njsBaton.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,8 @@ bool njsBaton_getFetchInfoFromArg(njsBaton *baton, napi_env env,
452452
return true;
453453

454454
// extract the property names from the object
455-
NJS_CHECK_NAPI(env, napi_get_property_names(env, value, &keys))
455+
if (!njsUtils_getOwnPropertyNames(env, value, &keys))
456+
return false;
456457

457458
// allocate space for the fetchInfo based on the number of keys
458459
NJS_CHECK_NAPI(env, napi_get_array_length(env, keys, &numElements))

src/njsConnection.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,9 +1994,8 @@ static bool njsConnection_processExecuteBinds(njsBaton *baton,
19941994

19951995
// if binding by name, get the list of bind names
19961996
bindNames = NULL;
1997-
if (!isArray) {
1998-
NJS_CHECK_NAPI(env, napi_get_property_names(env, binds, &bindNames))
1999-
}
1997+
if (!isArray && !njsUtils_getOwnPropertyNames(env, binds, &bindNames))
1998+
return false;
20001999

20012000
// initialize variables; if there are no variables, nothing further to do!
20022001
baton->bindArraySize = 1;
@@ -2069,9 +2068,8 @@ static bool njsConnection_processExecuteManyBinds(njsBaton *baton,
20692068

20702069
// get the list of bind names, if binding by name
20712070
bindNames = NULL;
2072-
if (!bindByPos) {
2073-
NJS_CHECK_NAPI(env, napi_get_property_names(env, bindDefs, &bindNames))
2074-
}
2071+
if (!bindByPos && !njsUtils_getOwnPropertyNames(env, bindDefs, &bindNames))
2072+
return false;
20752073

20762074
// initialize variables; if there are no variables, nothing further to do!
20772075
if (!njsConnection_initBindVars(baton, env, bindDefs, bindNames))

src/njsModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,8 @@ bool njsUtils_getError(napi_env env, dpiErrorInfo *errorInfo,
943943
bool njsUtils_getIntArg(napi_env env, napi_value *args, int index,
944944
int32_t *result);
945945
napi_value njsUtils_getNull(napi_env env);
946+
bool njsUtils_getOwnPropertyNames(napi_env env, napi_value value,
947+
napi_value *names);
946948
bool njsUtils_getStringArg(napi_env env, napi_value *args, int index,
947949
char **result, size_t *resultLength);
948950
bool njsUtils_getStringFromArg(napi_env env, napi_value *args,

src/njsUtils.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,27 @@ napi_value njsUtils_getNull(napi_env env)
508508
}
509509

510510

511+
//-----------------------------------------------------------------------------
512+
// njsUtils_getOwnPropertyNames()
513+
// Returns an array of property names owned specifically by the given object.
514+
//-----------------------------------------------------------------------------
515+
bool njsUtils_getOwnPropertyNames(napi_env env, napi_value value,
516+
napi_value *names)
517+
{
518+
napi_value global, globalObject, method;
519+
520+
NJS_CHECK_NAPI(env, napi_get_global(env, &global))
521+
NJS_CHECK_NAPI(env, napi_get_named_property(env, global, "Object",
522+
&globalObject))
523+
NJS_CHECK_NAPI(env, napi_get_named_property(env, globalObject,
524+
"getOwnPropertyNames", &method))
525+
NJS_CHECK_NAPI(env, napi_call_function(env, globalObject, method, 1,
526+
&value, names))
527+
528+
return true;
529+
}
530+
531+
511532
//-----------------------------------------------------------------------------
512533
// njsUtils_getStringArg()
513534
// Gets a string from the specified parameter. If the value is not a string,

0 commit comments

Comments
 (0)