diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2018-08-25 07:45:45 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2018-08-25 07:45:45 +0100 |
commit | 79cccf641486a6595c43f1de1cd7ade696020a31 (patch) | |
tree | 3db7b7a63c18fa6d763be4ba06a8e6a94009858c | |
parent | e5b46839994ec093251bb641fb7cbffe81712e40 (diff) |
Bug 699654(2): preserve LockSafetyParams in the nulldevice
The nulldevice does not necessarily use the normal setpagedevice machinery,
but can be set using the nulldevice operator. In which case, we don't preserve
the settings from the original device (in the way setpagedevice does).
Since nulldevice does nothing, this is not generally a problem, but in the case
of LockSafetyParams it *is* important when we restore back to the original
device, when LockSafetyParams not being set is "preserved" into the post-
restore configuration.
We have to initialise the value to false because the nulldevice is used during
initialisation (before any other device exists), and *must* be writable for
that.
-rw-r--r-- | base/gsdevice.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/base/gsdevice.c b/base/gsdevice.c index 06592208e..e38086dfd 100644 --- a/base/gsdevice.c +++ b/base/gsdevice.c | |||
@@ -691,7 +691,7 @@ int | |||
691 | gs_nulldevice(gs_gstate * pgs) | 691 | gs_nulldevice(gs_gstate * pgs) |
692 | { | 692 | { |
693 | int code = 0; | 693 | int code = 0; |
694 | 694 | bool saveLockSafety = false; | |
695 | if (pgs->device == 0 || !gx_device_is_null(pgs->device)) { | 695 | if (pgs->device == 0 || !gx_device_is_null(pgs->device)) { |
696 | gx_device *ndev; | 696 | gx_device *ndev; |
697 | code = gs_copydevice(&ndev, (const gx_device *)&gs_null_device, | 697 | code = gs_copydevice(&ndev, (const gx_device *)&gs_null_device, |
@@ -699,6 +699,8 @@ gs_nulldevice(gs_gstate * pgs) | |||
699 | 699 | ||
700 | if (code < 0) | 700 | if (code < 0) |
701 | return code; | 701 | return code; |
702 | if (gs_currentdevice_inline(pgs) != NULL) | ||
703 | saveLockSafety = gs_currentdevice_inline(pgs)->LockSafetyParams; | ||
702 | /* | 704 | /* |
703 | * Internal devices have a reference count of 0, not 1, | 705 | * Internal devices have a reference count of 0, not 1, |
704 | * aside from references from graphics states. | 706 | * aside from references from graphics states. |
@@ -718,6 +720,7 @@ gs_nulldevice(gs_gstate * pgs) | |||
718 | 720 | ||
719 | if ((code = gs_setdevice_no_erase(pgs, ndev)) < 0) | 721 | if ((code = gs_setdevice_no_erase(pgs, ndev)) < 0) |
720 | gs_free_object(pgs->memory, ndev, "gs_copydevice(device)"); | 722 | gs_free_object(pgs->memory, ndev, "gs_copydevice(device)"); |
723 | gs_currentdevice_inline(pgs)->LockSafetyParams = saveLockSafety; | ||
721 | } | 724 | } |
722 | return code; | 725 | return code; |
723 | } | 726 | } |