Skip to content

Commit f26e4c4

Browse files
committed
Fix memory leak of default fields in httpClose.
1 parent 51dcedb commit f26e4c4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ libcups v3.0.0 (YYYY-MM-DD)
99
- Fixed return values of `ippDateToTime` when the timezone isn't GMT.
1010
- Fixed a potential timing issue with `cupsEnumDests`.
1111
- Fixed a bug in the Avahi implementation of `cupsDNSSDBrowseNew`.
12+
- Fixed a memory leak in `httpClose`.
1213

1314

1415
libcups v3.0rc4 (2025-03-18)

cups/http.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ httpClearFields(http_t *http) // I - HTTP connection
273273
void
274274
httpClose(http_t *http) // I - HTTP connection
275275
{
276+
http_field_t field; // Current field
277+
278+
276279
DEBUG_printf("httpClose(http=%p)", (void *)http);
277280

278281
// Range check input...
@@ -285,9 +288,12 @@ httpClose(http_t *http) // I - HTTP connection
285288
// Free memory used...
286289
httpAddrFreeList(http->hostlist);
287290

288-
httpClearFields(http);
291+
for (field = HTTP_FIELD_ACCEPT; field < HTTP_FIELD_MAX; field ++)
292+
{
293+
free(http->default_fields[field]);
294+
free(http->fields[field]);
295+
}
289296

290-
free(http->fields[HTTP_FIELD_HOST]);
291297
free(http->authstring);
292298
free(http->cookie);
293299

0 commit comments

Comments
 (0)