Commit 4b643f1c authored by Marc Hoersken's avatar Marc Hoersken
Browse files

curl_schannel.c: Follow up on memory leak fix ae4558db

parent e73db5dc
Loading
Loading
Loading
Loading
+14 −10
Original line number Original line Diff line number Diff line
@@ -1132,17 +1132,21 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
      Curl_safefree(connssl->ctxt);
      Curl_safefree(connssl->ctxt);
    }
    }


    /* free SSPI Schannel API credential handle */
    if(connssl->cred) {
      /* decrement the reference counter of the credential/session handle */
      /* decrement the reference counter of the credential/session handle */
    if(connssl->cred && connssl->cred->refcount > 0) {
      if(connssl->cred->refcount > 0) {
        connssl->cred->refcount--;
        connssl->cred->refcount--;
        infof(data, "schannel: decremented credential handle refcount = %d\n",
        infof(data, "schannel: decremented credential handle refcount = %d\n",
              connssl->cred->refcount);
              connssl->cred->refcount);
      }
      }


      /* if the handle refcount is zero, check if we have not cached it */
      /* if the handle refcount is zero, check if we have not cached it */
    if(connssl->cred && connssl->cred->refcount == 0) {
      if(connssl->cred->refcount == 0) {
        if(Curl_ssl_getsessionid(conn, (void**)&cached_cred, NULL)) {
          cached_cred = NULL;
        }
        /* if the handle was not cached, it is stale to be freed */
        /* if the handle was not cached, it is stale to be freed */
      if(!Curl_ssl_getsessionid(conn, (void**)&cached_cred, NULL)) {
        if(connssl->cred != cached_cred) {
        if(connssl->cred != cached_cred) {
          infof(data, "schannel: clear credential handle\n");
          infof(data, "schannel: clear credential handle\n");
          s_pSecFn->FreeCredentialsHandle(&connssl->cred->cred_handle);
          s_pSecFn->FreeCredentialsHandle(&connssl->cred->cred_handle);