libcupsfilters: Memory leak fixed in imagetoraster() filter function
@@ -542,7 +542,7 @@ imagetoraster(int inputfd, /* I - File descriptor input stream */
}
else if (ipp != NULL) {
ippAttributeString(ipp, buf, sizeof(buf));
- val = strdup(buf);
+ val = buf;
}
else
{
@@ -589,16 +589,16 @@ imagetoraster(int inputfd, /* I - File descriptor input stream */
media_type = strdup(val);
}
else if(choice!=NULL)
- media_type = choice->choice;
+ media_type = strdup(choice->choice);
else if(ipp!=NULL){
- media_type = ippGetString(ipp, 0, NULL);
+ media_type = strdup(ippGetString(ipp, 0, NULL));
}
}
else
- media_type = "";
+ media_type = strdup("");
if ((choice = ppdFindMarkedChoice(ppd, "Resolution")) != NULL)
- resolution = choice->choice;
+ resolution = strdup(choice->choice);
else if ((val = cupsGetOption("Resolution", num_options, options)) != NULL ||
(ipp = ippFindAttribute(job_attrs, "printer-resolution",
IPP_TAG_ZERO))!=NULL)
@@ -635,7 +635,7 @@ imagetoraster(int inputfd, /* I - File descriptor input stream */
}
}
else
- resolution = "";
+ resolution = strdup("");
/* support the "cm-calibration" option */
cm_calibrate = cmGetCupsColorCalibrateMode(options, num_options);
@@ -1297,8 +1297,9 @@ imagetoraster(int inputfd, /* I - File descriptor input stream */
(val = cupsGetOption("PageSize", num_options, options)) != NULL ) {
if (val == NULL) {
ippAttributeString(ipp, buf, sizeof(buf));
- val = strdup(buf);
+ strcpy(defSize, buf);
}
+ else
snprintf(defSize, sizeof(defSize), "%s", val);
}
@@ -1918,7 +1919,8 @@ imagetoraster(int inputfd, /* I - File descriptor input stream */
/*
* Free memory used for the "zoom" engine...
*/
-
+ free(resolution);
+ free(media_type);
_cupsImageZoomDelete(z);
}
}
@@ -1928,6 +1930,8 @@ imagetoraster(int inputfd, /* I - File descriptor input stream */
*/
canceled:
+ free(resolution);
+ free(media_type);
free(row);
cupsRasterClose(ras);
cupsImageClose(img);
