aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-01-16 22:00:04 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-01-29 11:08:42 +0100
commit0422247a9d8259ef1a28704500f07caf827f42f6 (patch)
treeb4c23371322f06f2c45e13585ade124879347b9b /erts/emulator/beam
parentc334d4841d9d600237184233518ee13f7421f91c (diff)
downloadotp-0422247a9d8259ef1a28704500f07caf827f42f6.tar.gz
otp-0422247a9d8259ef1a28704500f07caf827f42f6.tar.bz2
otp-0422247a9d8259ef1a28704500f07caf827f42f6.zip
erts: Fix bug in erts_maps_remove
HRelease was called with wrong arguments and left garbage on heap when key was not found.
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r--erts/emulator/beam/erl_map.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c
index 455ba25e11..e68482be58 100644
--- a/erts/emulator/beam/erl_map.c
+++ b/erts/emulator/beam/erl_map.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2013. All Rights Reserved.
+ * Copyright Ericsson AB 2014. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -614,6 +614,7 @@ int erts_maps_remove(Process *p, Eterm key, Eterm map, Eterm *res) {
Sint n;
Sint found = 0;
Uint need;
+ Eterm *hp_start;
Eterm *thp, *mhp;
Eterm *ks, *vs, tup;
map_t *mp = (map_t*)map_val(map);
@@ -634,7 +635,8 @@ int erts_maps_remove(Process *p, Eterm key, Eterm map, Eterm *res) {
*/
need = n + 1 - 1 + 3 + n - 1; /* tuple - 1 + map - 1 */
- thp = HAlloc(p, need);
+ hp_start = HAlloc(p, need);
+ thp = hp_start;
mhp = thp + n; /* offset with tuple heap size */
tup = make_tuple(thp);
@@ -676,7 +678,7 @@ int erts_maps_remove(Process *p, Eterm key, Eterm map, Eterm *res) {
/* Not found, remove allocated memory
* and return previous map.
*/
- HRelease(p, thp + need, thp);
+ HRelease(p, hp_start + need, hp_start);
*res = map;
return 1;