--- http_negotiate.c	2008-02-17 10:38:20.000000000 -0500
+++ http_negotiate.c.patched	2008-02-21 06:26:28.000000000 -0500
@@ -244,6 +244,7 @@
   return 0;
 }
 
+static void cleanup_negotiate_ctx (struct negotiatedata *neg_ctx);
 
 CURLcode Curl_output_negotiate(struct connectdata *conn)
 {
@@ -301,14 +302,20 @@
   conn->allocptr.userpwd =
     aprintf("Authorization: %s %s\r\n", neg_ctx->protocol, encoded);
   free(encoded);
-  gss_release_buffer(&minor_status, &neg_ctx->output_token);
+
+  cleanup_negotiate_ctx (neg_ctx);
+
   return (conn->allocptr.userpwd == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
 }
 
 void Curl_cleanup_negotiate(struct SessionHandle *data)
 {
+  cleanup_negotiate_ctx (&data->state.negotiate);
+}
+
+static void cleanup_negotiate_ctx (struct negotiatedata *neg_ctx)
+{
   OM_uint32 minor_status;
-  struct negotiatedata *neg_ctx = &data->state.negotiate;
 
   if (neg_ctx->context != GSS_C_NO_CONTEXT)
     gss_delete_sec_context(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER);

