Make nested cursor array iteration safer

This avoids issues like setting Object.prototype.foo = some_value
This commit is contained in:
Christopher Jones 2020-02-29 09:26:54 +11:00
parent 9ecd0cc550
commit 35170fec43
1 changed files with 4 additions and 4 deletions

View File

@ -130,10 +130,10 @@ class ResultSet {
// determine the nested cursor indices to use, allowing for both
// OUT_FORMAT_ARRAY and OUT_FORMAT_OBJECT formats
let nestedCursorIndices = this._nestedCursorIndices;
const nestedCursorIndices = this._nestedCursorIndices;
if (outFormat == this._oracledb.OUT_FORMAT_OBJECT) {
const metadata = this.metaData;
for (const i in nestedCursorIndices) {
for (let i = 0; i < nestedCursorIndices.length; i++) {
nestedCursorIndices[i] = metadata[nestedCursorIndices[i]].name;
}
}
@ -152,9 +152,9 @@ class ResultSet {
const rows = await this._getRows(fetchArraySize, closeOnFetch,
closeOnAllRowsFetched);
if (nestedCursorIndices) {
for (const i in rows) {
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
for (const j in nestedCursorIndices) {
for (let j = 0; j < nestedCursorIndices.length; j++) {
const val = row[nestedCursorIndices[j]];
if (val) {
row[nestedCursorIndices[j]] =