Skip to content

Commit 8fa7819

Browse files
author
Robert Fancsik
authored
Fix memory leak in AtomicModifyWrite (#4944)
This patch fixes #4894. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent d681f20 commit 8fa7819

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

jerry-core/ecma/operations/ecma-atomics-object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ ecma_atomic_read_modify_write (ecma_value_t typedarray, /**< typedArray argument
192192
/* 9. */
193193
uint32_t indexed_position = ecma_number_to_uint32 (idx) * element_size + offset;
194194

195+
ecma_free_value (idx);
196+
195197
JERRY_UNUSED (indexed_position);
196198
JERRY_UNUSED (element_type);
197199
JERRY_UNUSED (val);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var sab = new SharedArrayBuffer(4);
16+
var a = new Int32Array(sab);
17+
18+
/* TODO: replace with the correct value whenever AtomicModifyWrite is properly implemented */
19+
assert(Atomics.add(a, -0, 1) === 0);

0 commit comments

Comments
 (0)