]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix memory leak in httpClose (Issue #1223)
authorMichael R Sweet <msweet@msweet.org>
Fri, 11 Apr 2025 13:51:00 +0000 (09:51 -0400)
committerMichael R Sweet <msweet@msweet.org>
Fri, 11 Apr 2025 13:51:08 +0000 (09:51 -0400)
cups/http.c

index dfefbacb807b9bb2d5686569e056eb561eeb17ca..613493ded1702b07d1e1f38d9f6613efa00880ad 100644 (file)
@@ -294,6 +294,7 @@ httpClearFields(http_t *http)               // I - HTTP connection
 void
 httpClose(http_t *http)                        // I - HTTP connection
 {
+  http_field_t field;                  // Current field
 #ifdef HAVE_GSSAPI
   OM_uint32    minor_status;           // Minor status code
 #endif // HAVE_GSSAPI
@@ -336,7 +337,12 @@ httpClose(http_t *http)                    // I - HTTP connection
     AuthorizationFree(http->auth_ref, kAuthorizationFlagDefaults);
 #endif // HAVE_AUTHORIZATION_H
 
-  httpClearFields(http);
+  for (field = HTTP_FIELD_ACCEPT; field < HTTP_FIELD_MAX; field ++)
+  {
+    free(http->default_fields[field]);
+    if (field >= HTTP_FIELD_ACCEPT_ENCODING || http->fields[field] != http->_fields[field])
+      free(http->fields[field]);
+  }
 
   if (http->authstring && http->authstring != http->_authstring)
     free(http->authstring);