Skip to content

Commit

Permalink
usrloc: fix memory leak on DB_ONLY mode on RPC commands
Browse files Browse the repository at this point in the history
(cherry picked from commit b97bb77)
  • Loading branch information
linuxmaniac authored and henningw committed Jul 2, 2019
1 parent 97cd5d0 commit 61b9f62
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/modules/usrloc/ul_rpc.c
Expand Up @@ -421,6 +421,7 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)

if (rpc->add(ctx, "{", &th) < 0)
{
release_urecord(rec);
unlock_udomain(dom, &aor);
rpc->fault(ctx, 500, "Internal error creating outer rpc");
return;
Expand All @@ -429,6 +430,7 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
"AoR", &aor,
"Contacts", &ih)<0)
{
release_urecord(rec);
unlock_udomain(dom, &aor);
rpc->fault(ctx, 500, "Internal error creating aor struct");
return;
Expand All @@ -439,12 +441,13 @@ static void ul_rpc_lookup(rpc_t* rpc, void* ctx)
if (VALID_CONTACT( con, act_time)) {
rpl_tree++;
if (rpc_dump_contact(rpc, ctx, ih, con) == -1) {
release_urecord(rec);
unlock_udomain(dom, &aor);
return;
}
}
}

release_urecord(rec);
unlock_udomain( dom, &aor);

if (rpl_tree==0) {
Expand Down Expand Up @@ -533,17 +536,20 @@ static void ul_rpc_rm_contact(rpc_t* rpc, void* ctx)

ret = get_ucontact( rec, &contact, &rpc_ul_cid, &rpc_ul_path, RPC_UL_CSEQ+1, &con);
if (ret < 0) {
release_urecord(rec);
unlock_udomain( dom, &aor);
rpc->fault(ctx, 500, "Internal error (can't get contact)");
return;
}
if (ret > 0) {
release_urecord(rec);
unlock_udomain( dom, &aor);
rpc->fault(ctx, 404, "Contact not found");
return;
}

if (delete_ucontact(rec, con) < 0) {
release_urecord(rec);
unlock_udomain( dom, &aor);
rpc->fault(ctx, 500, "Internal error (can't delete contact)");
return;
Expand Down

0 comments on commit 61b9f62

Please sign in to comment.