From 46a29e3f2cc953c390886a46fe2c43bd89aa4d82 Mon Sep 17 00:00:00 2001
From: Julien Wadel <julien.wadel@belledonne-communications.com>
Date: Thu, 14 Sep 2023 17:54:18 +0200
Subject: [PATCH] Account creator : Fix "invalid core" messages when validating
 uri.

---
 include/linphone/account_creator.h | 2 +-
 src/account_creator/main.cpp       | 6 +++---
 src/account_creator/utils.cpp      | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linphone/account_creator.h b/include/linphone/account_creator.h
index 9ce2472a17..d5afdcb7c2 100644
--- a/include/linphone/account_creator.h
+++ b/include/linphone/account_creator.h
@@ -32,7 +32,7 @@ extern "C" {
  */
 const char *_get_domain(LinphoneAccountCreator *creator);
 char *_get_identity(const LinphoneAccountCreator *creator);
-unsigned int validate_uri(const char *username, const char *domain, const char *display_name);
+unsigned int validate_uri(LinphoneCore *lc, const char *username, const char *domain, const char *display_name);
 void reset_field(char **field);
 void fill_domain_and_algorithm_if_needed(LinphoneAccountCreator *creator);
 char *generate_random_password(void);
diff --git a/src/account_creator/main.cpp b/src/account_creator/main.cpp
index 59a96a86fe..494b5b7fcb 100644
--- a/src/account_creator/main.cpp
+++ b/src/account_creator/main.cpp
@@ -127,7 +127,7 @@ LinphoneAccountCreatorUsernameStatus linphone_account_creator_set_username(Linph
 		return LinphoneAccountCreatorUsernameStatusInvalid;
 	} else if (regex && !bctbx_is_matching_regex(username, regex)) {
 		return LinphoneAccountCreatorUsernameStatusInvalidCharacters;
-	} else if (validate_uri(username, NULL, NULL) != 0) {
+	} else if (validate_uri(creator->core, username, NULL, NULL) != 0) {
 		return LinphoneAccountCreatorUsernameStatusInvalid;
 	}
 
@@ -311,7 +311,7 @@ const char *linphone_account_creator_get_language(const LinphoneAccountCreator *
 
 LinphoneAccountCreatorUsernameStatus linphone_account_creator_set_display_name(LinphoneAccountCreator *creator,
                                                                                const char *display_name) {
-	if (validate_uri(NULL, display_name, NULL) != 0) {
+	if (validate_uri(creator->core, NULL, display_name, NULL) != 0) {
 		return LinphoneAccountCreatorUsernameStatusInvalid;
 	}
 	set_string(&creator->display_name, display_name, FALSE);
@@ -340,7 +340,7 @@ const char *linphone_account_creator_get_email(const LinphoneAccountCreator *cre
 
 LinphoneAccountCreatorDomainStatus linphone_account_creator_set_domain(LinphoneAccountCreator *creator,
                                                                        const char *domain) {
-	if (domain && validate_uri(NULL, domain, NULL) != 0) {
+	if (domain && validate_uri(creator->core, NULL, domain, NULL) != 0) {
 		return LinphoneAccountCreatorDomainInvalid;
 	}
 
diff --git a/src/account_creator/utils.cpp b/src/account_creator/utils.cpp
index 6b4e9b0660..4ef7c67158 100644
--- a/src/account_creator/utils.cpp
+++ b/src/account_creator/utils.cpp
@@ -37,10 +37,10 @@ const char *_get_domain(LinphoneAccountCreator *creator) {
 	return NULL;
 }
 
-unsigned int validate_uri(const char *username, const char *domain, const char *display_name) {
+unsigned int validate_uri(LinphoneCore *lc, const char *username, const char *domain, const char *display_name) {
 	LinphoneAddress *addr;
 	unsigned int status = 0;
-	LinphoneProxyConfig *proxy = linphone_core_create_proxy_config(NULL);
+	LinphoneProxyConfig *proxy = linphone_core_create_proxy_config(lc);
 	addr = linphone_address_new("sip:?@domain.com");
 	linphone_proxy_config_set_identity_address(proxy, addr);
 	if (addr) linphone_address_unref(addr);
-- 
GitLab