diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c index 7b4aa0c..bc694f0 100644 --- a/cupsfilters/ppdgenerator.c +++ b/cupsfilters/ppdgenerator.c @@ -1059,9 +1059,11 @@ ippResolutionListToArray(ipp_attribute_t *attr) res_array = resolutionArrayNew(); if (res_array) { for (i = 0; i < count; i ++) - if ((res = ippResolutionToRes(attr, i)) != NULL && - cupsArrayFind(res_array, res) == NULL) - cupsArrayAdd(res_array, res); + if ((res = ippResolutionToRes(attr, i)) != NULL) { + if (cupsArrayFind(res_array, res) == NULL) + cupsArrayAdd(res_array, res); + free_resolution(res, NULL); + } } if (cupsArrayCount(res_array) == 0) { cupsArrayDelete(res_array); diff --git a/cupsfilters/ppdgenerator.h b/cupsfilters/ppdgenerator.h index 5e03e6d..050c320 100644 --- a/cupsfilters/ppdgenerator.h +++ b/cupsfilters/ppdgenerator.h @@ -71,6 +71,7 @@ char *ppdCreateFromIPP2(char *buffer, size_t bufsize, const char *default_cluster_color); int compare_resolutions(void *resolution_a, void *resolution_b, void *user_data); +void free_resolution(void *resolution, void *user_data); res_t * ippResolutionToRes(ipp_attribute_t *attr, int index); cups_array_t * resolutionArrayNew(); cups_array_t* generate_sizes(ipp_t *response, diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c index e2c9d38..8a882a1 100644 --- a/utils/cups-browsed.c +++ b/utils/cups-browsed.c @@ -1733,12 +1733,14 @@ void add_resolution_attributes(char* cluster_name, ipp_t **merged_attributes) if ((attr = ippFindAttribute(p->prattrs, attributes[attr_no], IPP_TAG_RESOLUTION)) != NULL) { for (i = 0, count = ippGetCount(attr); i < count; i ++) { - if ((res = ippResolutionToRes(attr, i)) != NULL && - cupsArrayFind(res_array, res) == NULL) { - cupsArrayAdd(res_array, res); - num_resolution ++; - } - } + if ((res = ippResolutionToRes(attr, i)) != NULL) { + if (cupsArrayFind(res_array, res) == NULL) { + cupsArrayAdd(res_array, res); + num_resolution ++; + } + free_resolution(res, NULL); + } + } } } if (num_resolution) { @@ -3219,6 +3221,7 @@ void get_cluster_default_attributes(ipp_t** merged_attributes, "printer-resolution-default", IPP_RES_PER_INCH, xres, yres); debug_printf("Default Resolution : %dx%d\n", xres, yres); + free_resolution(res, NULL); } } @@ -6157,7 +6160,7 @@ on_job_state (CupsNotifier *object, const char *pdl = NULL; cups_array_t *pdl_list; char resolution[32]; - res_t *max_res = NULL, *min_res = NULL, *res; + res_t *max_res = NULL, *min_res = NULL, *res = NULL; int xres, yres; int got_printer_info; static const char *pattrs[] = @@ -6504,6 +6507,10 @@ on_job_state (CupsNotifier *object, /* Deciding the resolution to be sent with the job */ /* Finding the minimum and maximum resolution supported by the printer */ + + max_res = resolutionNew(0, 0); + min_res = resolutionNew(0, 0); + if (s && ((attr = ippFindAttribute(s->prattrs, "printer-resolution-supported", IPP_TAG_RESOLUTION)) != NULL)) { @@ -6511,14 +6518,20 @@ on_job_state (CupsNotifier *object, if ((res = ippResolutionToRes(attr, i)) != NULL) { debug_printf("%d %d\n",res->x,res->y); if (i == 0) { - max_res = res; - min_res = res; + max_res->x = res->x; + max_res->y = res->y; + min_res->x = res->x; + min_res->y = res->y; } else { if(compare_resolutions((void *)res,(void *)max_res,NULL) > 0) - max_res = res; + max_res->x = res->x; + max_res->y = res->y; if(compare_resolutions((void *)res,(void *)min_res,NULL) < 0) - min_res = res; + min_res->x = res->x; + min_res->y = res->y; } + free_resolution(res, NULL); + res = NULL; } } } @@ -6555,10 +6568,14 @@ on_job_state (CupsNotifier *object, snprintf(resolution, sizeof(resolution), "%ddpi", xres); else snprintf(resolution, sizeof(resolution), "%dx%ddpi", xres, yres); + free_resolution(res, NULL); } } } + free_resolution(max_res, NULL); + free_resolution(min_res, NULL); + request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER); httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, "localhost", 0, "/printers/%s", printer);