Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
6c1dea8d
Commit
6c1dea8d
authored
13 years ago
by
Rafaël Carré
Browse files
Options
Downloads
Patches
Plain Diff
* #6392 : fix memory leak in sip account
parent
b67606c9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-common/src/sip/sipaccount.cpp
+34
-19
34 additions, 19 deletions
sflphone-common/src/sip/sipaccount.cpp
with
34 additions
and
19 deletions
sflphone-common/src/sip/sipaccount.cpp
+
34
−
19
View file @
6c1dea8d
...
@@ -73,6 +73,23 @@ void Credentials::unserialize (Conf::MappingNode *map)
...
@@ -73,6 +73,23 @@ void Credentials::unserialize (Conf::MappingNode *map)
credentialCount
=
atoi
(
val
->
getValue
().
data
());
credentialCount
=
atoi
(
val
->
getValue
().
data
());
}
}
namespace
{
static
void
free_cred
(
pjsip_cred_info
*
cred
)
{
if
(
!
cred
)
return
;
unsigned
i
;
unsigned
max
=
1
;
/* getCredentialCount() see #6408 */
for
(
i
=
0
;
i
<
max
;
i
++
)
{
free
(
cred
[
i
].
username
.
ptr
);
free
(
cred
[
i
].
data
.
ptr
);
free
(
cred
[
i
].
realm
.
ptr
);
}
free
(
cred
);
}
}
// end anonymous namespace
SIPAccount
::
SIPAccount
(
const
AccountID
&
accountID
)
SIPAccount
::
SIPAccount
(
const
AccountID
&
accountID
)
:
Account
(
accountID
,
"SIP"
)
:
Account
(
accountID
,
"SIP"
)
,
_routeSet
(
""
)
,
_routeSet
(
""
)
...
@@ -132,7 +149,7 @@ SIPAccount::~SIPAccount()
...
@@ -132,7 +149,7 @@ SIPAccount::~SIPAccount()
/* Delete accounts-related information */
/* Delete accounts-related information */
_regc
=
NULL
;
_regc
=
NULL
;
free
(
_cred
);
free
_cred
(
_cred
);
free
(
_tlsSetting
);
free
(
_tlsSetting
);
}
}
...
@@ -798,11 +815,11 @@ void SIPAccount::initCredential (void)
...
@@ -798,11 +815,11 @@ void SIPAccount::initCredential (void)
std
::
string
digest
;
std
::
string
digest
;
// Create the credential array
// Create the credential array
pjsip_cred_info
*
cred_info
=
(
pjsip_cred_info
*
)
free_cred
(
_cred
);
calloc
(
getCredentialCount
(),
sizeof
(
pjsip_cred_info
));
_cred
=
(
pjsip_cred_info
*
)
calloc
(
getCredentialCount
(),
sizeof
(
pjsip_cred_info
));
if
(
!
cred
_info
)
{
if
(
!
_
cred
)
{
_error
(
"SipAccount: Error: Failed to set cred
_info
for account %s"
,
_accountID
.
c_str
());
_error
(
"SipAccount: Error: Failed to set
_
cred for account %s"
,
_accountID
.
c_str
());
return
;
return
;
}
}
...
@@ -811,18 +828,18 @@ void SIPAccount::initCredential (void)
...
@@ -811,18 +828,18 @@ void SIPAccount::initCredential (void)
// Use authentication username if provided
// Use authentication username if provided
if
(
!
_authenticationUsername
.
empty
())
if
(
!
_authenticationUsername
.
empty
())
cred
_info
[
0
].
username
=
pj_str
(
strdup
(
_authenticationUsername
.
c_str
()));
_
cred
[
0
].
username
=
pj_str
(
strdup
(
_authenticationUsername
.
c_str
()));
else
else
cred
_info
[
0
].
username
=
pj_str
(
strdup
(
_username
.
c_str
()));
_
cred
[
0
].
username
=
pj_str
(
strdup
(
_username
.
c_str
()));
// Set password
// Set password
cred
_info
[
0
].
data
=
pj_str
(
strdup
(
_password
.
c_str
()));
_
cred
[
0
].
data
=
pj_str
(
strdup
(
_password
.
c_str
()));
// Set realm for that credential. * by default.
// Set realm for that credential. * by default.
cred
_info
[
0
].
realm
=
pj_str
(
strdup
(
_realm
.
c_str
()));
_
cred
[
0
].
realm
=
pj_str
(
strdup
(
_realm
.
c_str
()));
cred
_info
[
0
].
data_type
=
dataType
;
_
cred
[
0
].
data_type
=
dataType
;
cred
_info
[
0
].
scheme
=
pj_str
(
(
char
*
)
"digest"
);
_
cred
[
0
].
scheme
=
pj_str
(
(
char
*
)
"digest"
);
#if 0 // FIXME, unused. see https://projects.savoirfairelinux.com/issues/6408
#if 0 // FIXME, unused. see https://projects.savoirfairelinux.com/issues/6408
unsigned i;
unsigned i;
...
@@ -830,19 +847,17 @@ void SIPAccount::initCredential (void)
...
@@ -830,19 +847,17 @@ void SIPAccount::initCredential (void)
// Default credential already initialized, use credentials.getCredentialCount()
// Default credential already initialized, use credentials.getCredentialCount()
for (i = 0; i < credentials.getCredentialCount(); i++) {
for (i = 0; i < credentials.getCredentialCount(); i++) {
cred
_info
[i].username = pj_str (strdup (_username.c_str()));
_
cred[i].username = pj_str (strdup (_username.c_str()));
cred
_info
[i].data = pj_str (strdup (_password.c_str()));
_
cred[i].data = pj_str (strdup (_password.c_str()));
cred
_info
[i].realm = pj_str (strdup (_realm.c_str()));
_
cred[i].realm = pj_str (strdup (_realm.c_str()));
cred
_info
[i].data_type = dataType;
_
cred[i].data_type = dataType;
cred
_info
[i].scheme = pj_str ( (char*) "digest");
_
cred[i].scheme = pj_str ( (char*) "digest");
_debug ("Setting credential %u realm = %s passwd = %s username = %s data_type = %d", i, _realm.c_str(), _password.c_str(), _username.c_str(), cred
_info
[i].data_type);
_debug ("Setting credential %u realm = %s passwd = %s username = %s data_type = %d", i, _realm.c_str(), _password.c_str(), _username.c_str(),
_
cred[i].data_type);
}
}
#endif
#endif
_cred
=
cred_info
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment