diff options
author | Sverker Eriksson <[email protected]> | 2014-02-20 11:59:58 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2014-02-20 11:59:58 +0100 |
commit | a1c31504a7a75f74ec90f3aab8aa0e6fbfc20c33 (patch) | |
tree | fa8262365f5d9552df9e5fab759324fea6487de9 /erts | |
parent | d7889a517476a212831f87596dd7b232eed752f8 (diff) | |
download | otp-a1c31504a7a75f74ec90f3aab8aa0e6fbfc20c33.tar.gz otp-a1c31504a7a75f74ec90f3aab8aa0e6fbfc20c33.tar.bz2 otp-a1c31504a7a75f74ec90f3aab8aa0e6fbfc20c33.zip |
erts: Fix memory leak in nif_SUITE:resource_takeover
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_mod.c | 3 | ||||
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_mod.h | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_mod.c b/erts/emulator/test/nif_SUITE_data/nif_mod.c index aed8524635..55a0d2ac4f 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_mod.c +++ b/erts/emulator/test/nif_SUITE_data/nif_mod.c @@ -191,7 +191,8 @@ static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) add_call(env, data, "load"); do_load_info(env, load_info, &retval); - data->calls = 0; + if (retval) + NifModPrivData_release(data); return retval; } diff --git a/erts/emulator/test/nif_SUITE_data/nif_mod.h b/erts/emulator/test/nif_SUITE_data/nif_mod.h index cd0ecf4b54..fb14fee815 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_mod.h +++ b/erts/emulator/test/nif_SUITE_data/nif_mod.h @@ -14,7 +14,6 @@ typedef struct call_info_t typedef struct { ErlNifMutex* mtx; - int calls; int ref_cnt; CallInfo* call_history; ErlNifResourceType* rt_arr[RT_MAX]; @@ -28,6 +27,11 @@ typedef struct enif_mutex_unlock((NMPD)->mtx); \ if (is_last) { \ enif_mutex_destroy((NMPD)->mtx); \ + while ((NMPD)->call_history) { \ + CallInfo* next = (NMPD)->call_history->next; \ + enif_free((NMPD)->call_history); \ + (NMPD)->call_history = next; \ + } \ enif_free((NMPD)); \ } \ }while (0) |