Skip to content

Commit

Permalink
SYSDB: Use temporary memory context to allocate the results
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Cabrero <[email protected]>
  • Loading branch information
scabrero committed Jan 8, 2025
1 parent a47b596 commit 8b1aa90
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/db/sysdb_services.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ sysdb_getservbyport(TALLOC_CTX *mem_ctx,
goto done;
}

ret = sysdb_search_services(mem_ctx, domain, subfilter,
ret = sysdb_search_services(tmp_ctx, domain, subfilter,
attrs, &msgs_count, &msgs);
if (ret == EOK) {
res = talloc_zero(mem_ctx, struct ldb_result);
res = talloc_zero(tmp_ctx, struct ldb_result);
if (!res) {
ret = ENOMEM;
goto done;
Expand All @@ -151,8 +151,7 @@ sysdb_getservbyport(TALLOC_CTX *mem_ctx,
res->msgs = talloc_steal(res, msgs);
}

*_res = res;

*_res = talloc_move(mem_ctx, &res);

done:
talloc_free(tmp_ctx);
Expand Down

0 comments on commit 8b1aa90

Please sign in to comment.