From: Petr Štetiar Date: Tue, 8 Dec 2020 16:45:19 +0000 (+0100) Subject: uclient-fetch: fix potential memory leaks X-Git-Url: http://git.openwrt.org/source?a=commitdiff_plain;h=86a2ac6ac46ffb3f71e84debd03f7f16add148e5;p=project%2Fuclient.git uclient-fetch: fix potential memory leaks Fixes following issue reported by clang-12 static analyzer: uclient-fetch.c:612:25: warning: Potential leak of memory pointed to by 'username' [unix.Malloc] memset(optarg, '*', strlen(optarg)); ^~~~~~~~~~~~~~ uclient-fetch.c:618:25: warning: Potential leak of memory pointed to by 'password' [unix.Malloc] memset(optarg, '*', strlen(optarg)); ^~~~~~~~~~~~~~ Signed-off-by: Petr Štetiar --- diff --git a/uclient-fetch.c b/uclient-fetch.c index 0c7a123..1c66ac6 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -608,13 +608,13 @@ int main(int argc, char **argv) case L_USER: if (!strlen(optarg)) break; - username = strdup(optarg); + username = strdupa(optarg); memset(optarg, '*', strlen(optarg)); break; case L_PASSWORD: if (!strlen(optarg)) break; - password = strdup(optarg); + password = strdupa(optarg); memset(optarg, '*', strlen(optarg)); break; case L_USER_AGENT: