Skip to content

Commit ab49e08

Browse files
committed
Fix memory leak in streams subscribe/unsubscribe
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.
1 parent 7607df1 commit ab49e08

File tree

3 files changed

+127
-219
lines changed

3 files changed

+127
-219
lines changed

ldms/src/ldmsd/ldmsd_failover.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2299,7 +2299,7 @@ int failover_ping_handler(ldmsd_req_ctxt_t req)
22992299
ldmsd_failover_t f;
23002300
struct ldmsd_req_attr_s attr;
23012301
struct failover_ping_data data;
2302-
const char *name;
2302+
char *name;
23032303
const char *errstr = NULL;
23042304

23052305
ldms_xprt_priority_set(req->xprt->ldms.ldms, 1);
@@ -2336,8 +2336,10 @@ int failover_ping_handler(ldmsd_req_ctxt_t req)
23362336
attr.discrim = 0;
23372337
ldmsd_append_reply(req, (char *)&attr.discrim, sizeof(uint32_t),
23382338
LDMSD_REQ_EOM_F);
2339+
free(name);
23392340
return rc;
23402341
err:
2342+
free(name);
23412343
__failover_unlock(f);
23422344
req->errcode = rc;
23432345
ldmsd_send_req_response(req, errstr);

0 commit comments

Comments
 (0)