Skip to content

Commit

Permalink
Fix memory leak in streams subscribe/unsubscribe
Browse files Browse the repository at this point in the history
This change free()s strings allocated by calls to
ldmsd_req_attr_str_value_get_by_id() in the streams
subscribe and unsuscribe paths.

It also removes many of the code patterns that redundantly check for a
null pointer before calling free() because free() ignores a NULL ptr.
  • Loading branch information
tom95858 committed Apr 16, 2021
1 parent 7607df1 commit ab49e08
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 219 deletions.
4 changes: 3 additions & 1 deletion ldms/src/ldmsd/ldmsd_failover.c
Original file line number Diff line number Diff line change
Expand Up @@ -2299,7 +2299,7 @@ int failover_ping_handler(ldmsd_req_ctxt_t req)
ldmsd_failover_t f;
struct ldmsd_req_attr_s attr;
struct failover_ping_data data;
const char *name;
char *name;
const char *errstr = NULL;

ldms_xprt_priority_set(req->xprt->ldms.ldms, 1);
Expand Down Expand Up @@ -2336,8 +2336,10 @@ int failover_ping_handler(ldmsd_req_ctxt_t req)
attr.discrim = 0;
ldmsd_append_reply(req, (char *)&attr.discrim, sizeof(uint32_t),
LDMSD_REQ_EOM_F);
free(name);
return rc;
err:
free(name);
__failover_unlock(f);
req->errcode = rc;
ldmsd_send_req_response(req, errstr);
Expand Down
Loading

0 comments on commit ab49e08

Please sign in to comment.