diff options
| author | Hauke Mehrtens | 2026-05-31 15:38:38 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2026-06-03 23:20:02 +0000 |
| commit | d06d2a81dc29d746c5f13a9cc07ce779b5ed39be (patch) | |
| tree | 3a384d7f7fb14313e1d496aa230da6b25c5f20c2 | |
| parent | af5d6f431186bcd1847e9d3210652b09dbc90ce5 (diff) | |
| download | rpcd-d06d2a81dc29d746c5f13a9cc07ce779b5ed39be.tar.gz | |
rc: fix memory leak of list request context
rc_list() allocates a struct rc_list_context with calloc() and defers
the request; rc_list_readdir() walks /etc/init.d asynchronously and,
once the directory is exhausted (or the requested entry was found),
sends the reply and completes the deferred request -- but never frees
the context. free(c) only existed in the early opendir() failure path,
so every successful "rc list" ubus call leaked the context (which embeds
a PATH_MAX sized path buffer), slowly exhausting memory.
Free the context in the terminal path after completing the request.
Assisted-by: Claude:claude-opus-4-8
Link: https://github.com/openwrt/rpcd/pull/34
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rw-r--r-- | rc.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -193,6 +193,7 @@ static void rc_list_readdir(struct rc_list_context *c) closedir(c->dir); ubus_send_reply(c->ctx, &c->req, c->buf->head); ubus_complete_deferred_request(c->ctx, &c->req, UBUS_STATUS_OK); + free(c); return; } |