PPD parser: Only last "Emulators" statement is taken into account + memory leak#5475
Closed
ppawliczek wants to merge 1 commit intoapple:masterfrom
ppawliczek:leak_in_ppd_emulations
Closed
PPD parser: Only last "Emulators" statement is taken into account + memory leak#5475ppawliczek wants to merge 1 commit intoapple:masterfrom ppawliczek:leak_in_ppd_emulations
ppawliczek wants to merge 1 commit intoapple:masterfrom
ppawliczek:leak_in_ppd_emulations
Conversation
…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.
Collaborator
|
Happy to fix this, but keep in mind that CUPS never uses the value and PPDs are long deprecated... |
| ppd->landscape = -90; | ||
| ppd->coptions = cupsArrayNew((cups_array_func_t)ppd_compare_coptions, | ||
| NULL); | ||
| ppd->emulations = NULL; |
Collaborator
There was a problem hiding this comment.
Unnecessary because ppd_file_t structure is zeroed.
|
|
||
| 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)); |
Collaborator
There was a problem hiding this comment.
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...
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.