core: fix memory leak if url change fails
authorFelix Fietkau <nbd@openwrt.org>
Sat, 16 Jan 2016 19:13:36 +0000 (20:13 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 16 Jan 2016 21:18:55 +0000 (22:18 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
uclient.c

index 21f6f5dafdb5b1d3d6423de9819ba64060f0bb79..2113d8dc795c621c43ce9631a15d3a3151d691dc 100644 (file)
--- a/uclient.c
+++ b/uclient.c
@@ -182,8 +182,10 @@ int uclient_set_url(struct uclient *cl, const char *url_str, const char *auth_st
        if (!url)
                return -1;
 
-       if (url->backend != cl->backend)
+       if (url->backend != cl->backend) {
+               free(url);
                return -1;
+       }
 
        free(cl->url);
        cl->url = url;