summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-04-23 22:11:46 +0000
committerHauke Mehrtens2026-06-07 11:23:06 +0000
commitf227ab4f1285237d58f138a69fc69b37ae774b46 (patch)
tree2f1d3953ad08b650e57c4c055f2ef7552ec29e20
parent7a0aa2e4afb4993b7985094aa6847b9fcb04fae8 (diff)
downloaduclient-f227ab4f1285237d58f138a69fc69b37ae774b46.tar.gz
uclient: fix memory leak of url when backend alloc fails
If backend->alloc() returned NULL, uclient_new() returned without freeing the url structure parsed earlier, leaking it. Assisted-by: Claude:claude-opus-4-7 Link: https://github.com/openwrt/uclient/pull/16 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--uclient.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/uclient.c b/uclient.c
index 0fb92b8..76f562c 100644
--- a/uclient.c
+++ b/uclient.c
@@ -257,8 +257,10 @@ struct uclient *uclient_new(const char *url_str, const char *auth_str, const str
return NULL;
cl = url->backend->alloc();
- if (!cl)
+ if (!cl) {
+ free(url);
return NULL;
+ }
cl->backend = url->backend;
cl->cb = cb;