Skip to content

Commit 7b5745d

Browse files
committed
usrloc cluster: Fix possible SHM memory leak
Commit 343f452 included a possible memory leak whenever the .kv_storage field was already allocated in the urecord_t structure. (cherry picked from commit 1c505c5)
1 parent 47bb121 commit 7b5745d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

modules/usrloc/ul_cluster.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ static int receive_urecord_insert(bin_packet_t *packet)
428428
{
429429
str d, aor, kv_str;
430430
urecord_t *r;
431+
map_t kv_storage;
431432
udomain_t *domain;
432433
int sl;
433434
short pkg_ver = get_bin_pkg_version(packet);
@@ -463,7 +464,11 @@ static int receive_urecord_insert(bin_packet_t *packet)
463464

464465
if (pkg_ver >= UL_BIN_V5) {
465466
bin_pop_str(packet, &kv_str);
466-
r->kv_storage = store_deserialize(&kv_str);
467+
kv_storage = store_deserialize(&kv_str);
468+
if (kv_storage) {
469+
store_destroy(r->kv_storage);
470+
r->kv_storage = kv_storage;
471+
}
467472
}
468473

469474
out:

0 commit comments

Comments
 (0)