Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

PPD parser: Only last "Emulators" statement is taken into account + memory leak#5475

Closed
ppawliczek wants to merge 1 commit into
apple:masterfrom
ppawliczek:leak_in_ppd_emulations
Closed

PPD parser: Only last "Emulators" statement is taken into account + memory leak#5475
ppawliczek wants to merge 1 commit into
apple:masterfrom
ppawliczek:leak_in_ppd_emulations

Conversation

@ppawliczek

Copy link
Copy Markdown

Each occurence of "Emulators" keyword overwrites the previous parsed
"Emulators" statement. It also causes a memory leak. The problem is solved here
by concatenating together values from all occurences of "Emulators" statements.

…emory leak

Each occurence of "Emulators" keyword overwrites the previous parsed
"Emulators" statement. It also causes a memory leak. The problem is solved here
by concatenating together values from all occurences of "Emulators" statements.
@michaelrsweet

Copy link
Copy Markdown
Contributor

Happy to fix this, but keep in mind that CUPS never uses the value and PPDs are long deprecated...

@michaelrsweet michaelrsweet added this to the CUPS 2.2.x Updates milestone Jan 9, 2019
@michaelrsweet michaelrsweet self-assigned this Jan 9, 2019
Comment thread cups/ppd.c
ppd->landscape = -90;
ppd->coptions = cupsArrayNew((cups_array_func_t)ppd_compare_coptions,
NULL);
ppd->emulations = NULL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary because ppd_file_t structure is zeroed.

Comment thread cups/ppd.c

ppd->num_emulations = count;
if ((ppd->emulations = calloc((size_t)count, sizeof(ppd_emul_t))) == NULL)
temp_ptr = realloc(ppd->emulations, (size_t)(ppd->num_emulations+count)*sizeof(ppd_emul_t));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, CUPS runs on platforms where realloc(NULL, size) will crash hard. But I can refactor this.

michaelrsweet added a commit that referenced this pull request Jan 21, 2019
This also eliminates a potential memory leak...
michaelrsweet added a commit that referenced this pull request Jan 21, 2019
This also addresses a potential memory leak...
@michaelrsweet

Copy link
Copy Markdown
Contributor

I opted to just remove the code that deals with the emulations array completely - nothing in CUPS uses this array and it was just more "dead code" cluttering up libcups.

[master 4b5a691] Stop parsing the Emulators keywords in PPD files (Issue #5475)

[branch-2.2 558bba7] Stop parsing the Emulators keywords in PPD files (Issue #5475)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants