aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-04-20 20:01:40 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-04-20 20:04:00 +0100
commitbddf3d4705ed8e0999200c92de191db8e2441b3a (patch)
treeb63f7107671b527539dbddaf08cefcbc75caffcc
parente99c81a07c0c8752a286e0f14174ae7ae114090c (diff)
url: Simplified setstropt_userpwd() following recent changes
There is no need to perform separate clearing of data if a NULL option pointer is passed in. Instead this operation can be performed by simply not calling parse_login_details() and letting the rest of the code do the work.
-rw-r--r--lib/url.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/lib/url.c b/lib/url.c
index 4f995ab54..8601ade6e 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -305,31 +305,15 @@ static CURLcode setstropt_userpwd(char *option, char **user_storage,
char *passwdp = NULL;
char *optionsp = NULL;
- if(!option) {
- /* we treat a NULL passed in as a hint to clear existing info */
- if(user_storage) {
- Curl_safefree(*user_storage);
- *user_storage = (char *) NULL;
- }
-
- if(pwd_storage) {
- Curl_safefree(*pwd_storage);
- *pwd_storage = (char *) NULL;
- }
-
- if(options_storage) {
- Curl_safefree(*options_storage);
- *options_storage = (char *) NULL;
- }
-
- return CURLE_OK;
+ /* Parse the login details if specified. It not then we treat NULL as a hint
+ to clear the existing data */
+ if(option) {
+ result = parse_login_details(option, strlen(option),
+ (user_storage ? &userp : NULL),
+ (pwd_storage ? &passwdp : NULL),
+ (options_storage ? &optionsp : NULL));
}
- /* Parse the login details */
- result = parse_login_details(option, strlen(option),
- (user_storage ? &userp : NULL),
- (pwd_storage ? &passwdp : NULL),
- (options_storage ? &optionsp : NULL));
if(!result) {
/* store username part of option */
if(user_storage) {