]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Save the new cookie pointer.
authorMichael R Sweet <msweet@msweet.org>
Thu, 1 May 2025 23:09:25 +0000 (19:09 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 1 May 2025 23:09:25 +0000 (19:09 -0400)
cups/http.c

index 823ac7bec4c98801a15b230d9bdc163b1e986a95..4bfb74f0346370a1ba53f9d6f89e28b80fec2eaf 100644 (file)
@@ -230,11 +230,8 @@ httpClearCookie(http_t *http)              // I - HTTP connection
   if (!http)
     return;
 
-  if (http->cookie)
-  {
-    free(http->cookie);
-    http->cookie = NULL;
-  }
+  free(http->cookie);
+  http->cookie = NULL;
 }
 
 
@@ -321,8 +318,7 @@ httpClose(http_t *http)                     // I - HTTP connection
 
   httpAddrFreeList(http->addrlist);
 
-  if (http->cookie)
-    free(http->cookie);
+  free(http->cookie);
 
 #ifdef HAVE_GSSAPI
   if (http->gssctx != GSS_C_NO_CONTEXT)
@@ -2666,7 +2662,8 @@ httpSetCookie(http_t     *http,           // I - HTTP cnnection
     if ((temp = realloc(http->cookie, ctotal)) == NULL)
       return;
 
-    temp[clen] = '\n';
+    http->cookie = temp;
+    temp[clen]   = '\n';
     cupsCopyString(temp + clen + 1, cookie, ctotal - clen - 1);
   }
   else
@@ -3511,7 +3508,7 @@ httpWriteResponse(http_t        *http,    // I - HTTP connection
            return (-1);
          }
        }
-       else if (httpPrintf(http, "Set-Cookie: %s; path=/; httponly;%s\r\n", http->cookie, http->tls ? " secure;" : "") < 1)
+       else if (httpPrintf(http, "Set-Cookie: %s; path=/; httponly;%s\r\n", start, http->tls ? " secure;" : "") < 1)
        {
          http->status = HTTP_STATUS_ERROR;
          if (ptr)