client session BUGFIX ch client binds memory handling
diff --git a/src/session_client.c b/src/session_client.c
index a3e010f..f01a57e 100644
--- a/src/session_client.c
+++ b/src/session_client.c
@@ -1020,8 +1020,13 @@
free((char *)client_opts.ch_binds[i].address);
--client_opts.ch_bind_count;
- memcpy(&client_opts.ch_binds[i], &client_opts.ch_binds[client_opts.ch_bind_count], sizeof *client_opts.ch_binds);
- client_opts.ch_bind_ti[i] = client_opts.ch_bind_ti[client_opts.ch_bind_count];
+ if (!client_opts.ch_bind_count) {
+ free(client_opts.ch_binds);
+ client_opts.ch_binds = NULL;
+ } else if (i < client_opts.ch_bind_count) {
+ memcpy(&client_opts.ch_binds[i], &client_opts.ch_binds[client_opts.ch_bind_count], sizeof *client_opts.ch_binds);
+ client_opts.ch_bind_ti[i] = client_opts.ch_bind_ti[client_opts.ch_bind_count];
+ }
ret = 0;
}