Skip to content

Commit b0deb1a

Browse files
authored
Fix NewTransaction method (#78)
1 parent 64532b3 commit b0deb1a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/api/string_methods.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ void AddSecureMarksToTaintedString(const FunctionCallbackInfo<Value>& args) {
151151
}
152152

153153
uintptr_t transactionId = utils::GetLocalStringPointer(transactionIdArgument);
154-
auto transaction = NewTransaction(transactionId);
154+
155+
auto transaction = GetTransaction(transactionId);
155156
if (transaction == nullptr) {
156157
return;
157158
}

src/transaction_manager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class TransactionManager {
2020
void operator=(TransactionManager const&) = delete;
2121

2222
T* New(U id) {
23-
if (_map.size() >= _maxItems) {
24-
return nullptr;
25-
}
26-
2723
auto found = _map.find(id);
2824
if (found == _map.end()) {
25+
if (_map.size() >= _maxItems) {
26+
return nullptr;
27+
}
28+
2929
T* item = _pool.Pop(id);
3030
_map[id] = item;
3131
return item;

test/js/new_tainted_string.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ describe('Taint strings', function () {
1111
const value = 'test'
1212
const id = TaintedUtils.createTransaction('1')
1313

14+
before(() => {
15+
TaintedUtils.setMaxTransactions(1)
16+
})
17+
1418
afterEach(function () {
1519
TaintedUtils.removeTransaction(id)
1620
})
1721

22+
after(() => {
23+
TaintedUtils.setMaxTransactions(2)
24+
})
25+
1826
it('Taint new string with undefined transaction', function () {
1927
const ret = TaintedUtils.newTaintedString(undefined, value, 'param', 'REQUEST')
2028
assert.strictEqual(ret, 'test', 'Unexpected value')

0 commit comments

Comments
 (0)