diff --git a/src/auth.cc b/src/auth.cc index 1ac7fc4..063d6c0 100644 --- a/src/auth.cc +++ b/src/auth.cc @@ -48,7 +48,7 @@ struct AuthHost_t struct AuthDialogData_t { const AuthParse_t *auth_parse; - const DilloUrl *url; + std::unique_ptr< const DilloUrl > url; }; /** @@ -538,7 +538,7 @@ static void Auth_do_auth_dialog_cb(const char *user, const char *password, data = (AuthDialogData_t *)vData; /* find or create the host */ - if (!(host = Auth_host_by_url(data->url))) { + if (!(host = Auth_host_by_url(data->url.get()))) { /* create a new host */ host = std::make_unique< AuthHost_t >().release(); host->scheme = dStrdup(URL_SCHEME(data->url)); @@ -606,7 +606,6 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse, { int ret; char *title, *msg; - AuthDialogData_t *data; const char *typestr = auth_parse->type == DIGEST ? "Digest" : "Basic"; _MSG("auth.c: Auth_do_auth_dialog: realm = '%s'\n", auth_parse->realm); @@ -615,13 +614,11 @@ static int Auth_do_auth_dialog(const AuthParse_t *auth_parse, msg = dStrconcat("The server at ", URL_HOST(url), " requires a username" " and password for \"", auth_parse->realm, "\".\n\n" "Authentication scheme: ", typestr, NULL); - data = std::make_unique< AuthDialogData_t >().release(); + auto data = std::make_unique< AuthDialogData_t >(); data->auth_parse = auth_parse; - data->url = a_Url_dup(url).release(); - ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data); + data->url = a_Url_dup(url); + ret = a_Dialog_user_password(title, msg, Auth_do_auth_dialog_cb, data.get()); dFree(title); dFree(msg); - delete const_cast< DilloUrl * >( data->url ); - delete data; return ret; }