Skip to content

Commit b0ca537

Browse files
authored
Correctly release values in Proxy.[[Get]] (#4477)
In Proxy.[[Get]] if the target.[[GetOwnPropertyDescriptor]] fails the trap result should be freed. Fixes: #4466 JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent 9ce7e49 commit b0ca537

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */
11581158
/* 12. */
11591159
if (ECMA_IS_VALUE_ERROR (status))
11601160
{
1161+
ecma_free_value (trap_result);
11611162
return status;
11621163
}
11631164

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 called_get = false;
16+
var targetProxy = new Proxy({}, {
17+
getOwnPropertyDescriptor: function(target, key) {
18+
throw new URIError("Generate error");
19+
}
20+
});
21+
22+
var px = new Proxy(targetProxy, {
23+
get: function(target, key) {
24+
called_get = true;
25+
return { debug: 1 };
26+
}
27+
});
28+
29+
try {
30+
px.abc;
31+
assert(false);
32+
} catch (ex) {
33+
assert(ex instanceof URIError);
34+
assert(called_get === true);
35+
}

0 commit comments

Comments
 (0)