libssh legacy logging breaks multiple sessions

Used Version: 0.10.6

I've found an issue with the LEGACY logging code in ssh_set_callbacks:

Small example:

void my_log_function(ssh_session session, int priority, const char* message, void* userdata)
{
  // do some custom logging for the session
}

ssh_session session1 = ssh_new();
ssh_callbacks_struct callbacks = {};
callbacks.log_function = my_log_function;

ssh_callbacks_init(&callbacks);
ssh_set_callbacks(session1, &callbacks);

// ... do something with the session, e.g
ssh_connect(session1);

ssh_free(session1);

ssh_session session2 = ssh_new();
ssh_callbacks_struct callbacks2 = {};
callbacks2.log_function = my_log_function;

ssh_callbacks_init(&callbacks2);
ssh_set_callbacks(session2, &callbacks2);

ssh_connect(session2); // segmentation fault accessing session1 in ssh_legacy_log_callback stored in the thread local userdata pointer

its caused by the code

  /* LEGACY */
  if (ssh_get_log_callback() == NULL && cb->log_function) {
      ssh_set_log_callback(ssh_legacy_log_callback);
      ssh_set_log_userdata(session);
  }

My current workaround is to "reset" the thread local ssh_log_cb to an empty callback function doing nothing

void my_ssh_legacy_log_callback(int priority, const char* function, const char* buffer, void* userdata)
{
  // do nothing
}

ssh_set_log_callback(my_ssh_legacy_log_callback);

since you can neither use ssh_set_log_callback(NULL) nor ssh_set_log_userdata(NULL) to reset the (unnecessary?) callback function and/or the access to that first session.

Perhaps it's a good point to remove that legacy code completely, or at least document this behavior somewhere.