Skip to content

Commit 5c7c4e4

Browse files
Michal StruweSESA747457
authored andcommitted
session_server: only free attr_p if it was allocated before
1 parent 0f118c3 commit 5c7c4e4

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/session_server.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,9 +854,11 @@ nc_server_init(void)
854854
goto error;
855855
}
856856

857+
#ifdef HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP
857858
if (attr_p) {
858859
pthread_rwlockattr_destroy(attr_p);
859860
}
861+
#endif
860862

861863
#ifdef NC_ENABLED_SSH_TLS
862864
if (curl_global_init(CURL_GLOBAL_SSL | CURL_GLOBAL_ACK_EINTR)) {
@@ -898,9 +900,11 @@ nc_server_init(void)
898900
return 0;
899901

900902
error:
903+
#ifdef HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP
901904
if (attr_p) {
902905
pthread_rwlockattr_destroy(attr_p);
903906
}
907+
#endif
904908
return -1;
905909
}
906910

@@ -2766,11 +2770,14 @@ nc_connect_ch_endpt(struct nc_ch_endpt *endpt, nc_server_ch_session_acquire_ctx_
27662770
const struct ly_ctx *ctx = NULL;
27672771
int sock, ret;
27682772
struct timespec ts_cur;
2769-
char *ip_host;
2773+
char *ip_host = NULL;
27702774

27712775
sock = nc_sock_connect(endpt->src_addr, endpt->src_port, endpt->dst_addr, endpt->dst_port,
27722776
NC_CH_CONNECT_TIMEOUT, &endpt->ka, &endpt->sock_pending, &ip_host);
27732777
if (sock < 0) {
2778+
if (ip_host) {
2779+
free(ip_host);
2780+
}
27742781
return NC_MSG_ERROR;
27752782
}
27762783

@@ -3990,6 +3997,7 @@ nc_server_notif_cert_exp_thread(void *arg)
39903997

39913998
/* config changed, reload the certificates and intervals */
39923999
nc_server_notif_cert_exp_dates_destroy(exp_dates, exp_date_count);
4000+
exp_dates = NULL;
39934001

39944002
nc_server_notif_cert_exp_intervals_get(default_intervals, 3, &intervals, &interval_count);
39954003

@@ -4030,7 +4038,9 @@ nc_server_notif_cert_exp_thread(void *arg)
40304038
if (targ->clb_free_data) {
40314039
targ->clb_free_data(targ->clb_data);
40324040
}
4033-
nc_server_notif_cert_exp_dates_destroy(exp_dates, exp_date_count);
4041+
if (exp_dates) {
4042+
nc_server_notif_cert_exp_dates_destroy(exp_dates, exp_date_count);
4043+
}
40344044
free(targ);
40354045
return NULL;
40364046
}

0 commit comments

Comments
 (0)