-
Notifications
You must be signed in to change notification settings - Fork 195
Closed
Labels
is:bugBug description.Bug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)From the developer perspective, the issue was solved (bug fixed, question answered,...)
Description
Hi, developers, thank you for your checking. The lock &stats.lock may not be correctly released if the realloc fails. Finally, the method returns with the unreleased lock. The fix is to insert pthread_mutex_unlock(&stats.lock); before returning.
netopeer2/src/netconf_monitoring.c
Line 143 in a68ff29
| ncm_session_add(struct nc_session *session) |
netopeer2/src/netconf_monitoring.c
Line 153 in a68ff29
| pthread_mutex_lock(&stats.lock); |
void
ncm_session_add(struct nc_session *session)
{
...;
pthread_mutex_lock(&stats.lock);
++stats.in_sessions;
++stats.session_count;
new = realloc(stats.sessions, stats.session_count * sizeof *stats.sessions);
if (!new) {
EMEM;
return; //return without releasing the lock
}
stats.sessions = new;
new = realloc(stats.session_stats, stats.session_count * sizeof *stats.session_stats);
if (!new) {
EMEM;
return; //return without releasing the lock
}
...;
pthread_mutex_unlock(&stats.lock);
}
Best,
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
is:bugBug description.Bug description.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)From the developer perspective, the issue was solved (bug fixed, question answered,...)