Browse Source

uclient-utils: Handle memory allocation failure for url file name

Add null pointer check to allocation of url filename

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
Tobias Schramm 6 years ago
parent
commit
eb850df457
1 changed files with 1 additions and 1 deletions
  1. 1 1
      uclient-utils.c

+ 1 - 1
uclient-utils.c

@@ -178,7 +178,7 @@ char *uclient_get_url_filename(const char *url, const char *default_name)
 	len -= str - url;
 
 	if (len > 0)
-		return strncpy(calloc(1, len + 1), str, len);
+		return strndup(str, len);
 
 	return strdup(default_name);
 }