From: Zdenek Dohnal Date: Tue, 20 Sep 2022 16:00:15 +0000 (+0200) Subject: scheduler: Fix memory leaks during create_local_bg_thread() X-Git-Tag: v2.4.3~127^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F469%2Fhead;p=thirdparty%2Fcups.git scheduler: Fix memory leaks during create_local_bg_thread() --- diff --git a/cups/ppd-cache.c b/cups/ppd-cache.c index f72d834f5d..594290a852 100644 --- a/cups/ppd-cache.c +++ b/cups/ppd-cache.c @@ -3269,20 +3269,20 @@ _ppdCreateFromIPP2( { keyword = ippGetString(lang_supp, i, NULL); - request = ippNew(); - ippSetOperation(request, IPP_OP_GET_PRINTER_ATTRIBUTES); - ippSetRequestId(request, i + 1); - ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_CHARSET), "attributes-charset", NULL, "utf-8"); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, keyword); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri); - ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", NULL, "printer-strings-uri"); + request = ippNew(); + ippSetOperation(request, IPP_OP_GET_PRINTER_ATTRIBUTES); + ippSetRequestId(request, i + 1); + ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_CHARSET), "attributes-charset", NULL, "utf-8"); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, keyword); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri); + ippAddString(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", NULL, "printer-strings-uri"); - response = cupsDoRequest(http, request, resource); + response = cupsDoRequest(http, request, resource); - if ((attr = ippFindAttribute(response, "printer-strings-uri", IPP_TAG_URI)) != NULL) - { + if ((attr = ippFindAttribute(response, "printer-strings-uri", IPP_TAG_URI)) != NULL) cupsFilePrintf(fp, "*cupsStringsURI %s: \"%s\"\n", keyword, ippGetString(attr, 0, NULL)); - } + + ippDelete(response); } } } @@ -4994,6 +4994,8 @@ _ppdCreateFromIPP2( cupsFileClose(fp); + _cupsMessageFree(strings); + return (buffer); /* @@ -5006,6 +5008,8 @@ _ppdCreateFromIPP2( unlink(buffer); *buffer = '\0'; + _cupsMessageFree(strings); + _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Printer does not support required IPP attributes or document formats."), 1); return (NULL); diff --git a/scheduler/ipp.c b/scheduler/ipp.c index bea2ad9584..f0b31b432d 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -5401,6 +5401,7 @@ create_local_bg_thread( if ((from = cupsFileOpen(fromppd, "r")) == NULL) { cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Unable to read generated PPD: %s", printer->name, strerror(errno)); + ippDelete(response); return (NULL); } @@ -5408,6 +5409,7 @@ create_local_bg_thread( if ((to = cupsdCreateConfFile(toppd, ConfigFilePerm)) == NULL) { cupsdLogMessage(CUPSD_LOG_ERROR, "%s: Unable to create PPD for printer: %s", printer->name, strerror(errno)); + ippDelete(response); cupsFileClose(from); return (NULL); } @@ -5431,6 +5433,8 @@ create_local_bg_thread( else cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed: %s", printer->name, cupsLastErrorString()); + ippDelete(response); + return (NULL); }