Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

ppawliczek
Copy link

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
Collaborator

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
@@ -654,6 +655,7 @@ _ppdOpen(
ppd->landscape = -90;
ppd->coptions = cupsArrayNew((cups_array_func_t)ppd_compare_coptions,
NULL);
ppd->emulations = NULL;
Copy link
Collaborator

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.

@@ -1202,27 +1204,32 @@ _ppdOpen(
sptr ++;
}

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
Collaborator

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
Collaborator

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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants