Skip to content

A crash when ippDelete(request) or ippDelete(response) is called #1349

@shilaoer1991

Description

@shilaoer1991

Hello
I use cupsSendRequest to get printer status information. After successfully calling cupsGetResponse, should I immediately delete the request object with ippDelete? If I read the response attributes first and then call ippDelete in sequence, will there be any issues?

This is my code:

ipp_t *request = NULL;
 ipp_t *response = NULL;
 http_status_t result;
 request = ippNewRequest(op);
 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);
 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
         sizeof(pattrs) / sizeof(pattrs[0]), NULL, pattrs);

 do {
     result = cupsSendRequest(http, request, resource, ippLength(request));
     if (result <= HTTP_STATUS_CONTINUE || result == HTTP_STATUS_OK) {
         response = cupsGetResponse(http, resource);
         result = httpGetStatus(http);
     }

     if (result == HTTP_STATUS_ERROR ||  (result >= HTTP_STATUS_BAD_REQUEST && 
         result != HTTP_STATUS_UNAUTHORIZED && result != HTTP_STATUS_UPGRADE_REQUIRED)) {
         _cupsSetHTTPError(result);
         break;
     }

     if (http->state != HTTP_STATE_WAITING) {
         httpFlush(http);
     }
 } while (response == NULL);
 
 if (response  && (attrptr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) {
      printer_ippstate = (ipp_pstate_t) ippGetInteger(attrptr, 0);
 }

 ippDelete(request);
 ippDelete(response);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions