summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2018-11-19 09:00:54 +0000
committerChris Liddell <chris.liddell@artifex.com>2018-11-19 09:50:37 +0000
commita4228a0d8d657fca3bb3becb93a43fae061beae8 (patch)
tree87b8d2eb381eab572e0c40559d70d8d501b27abe
parentc796ccb512ac581f5ac492fda8807d41769c47e8 (diff)
downloadghostpdl-a4228a0d8d657fca3bb3becb93a43fae061beae8.tar.gz
Coverity ID 327264 - move pointer NULL check
Due to recent changes in this code, the pointer was being dereferenced before we checked it to see if it was NULL. Moe the check so that we check for NULL before dereferencing. The 'pvalue' of the operand can be NULL, even if the object is a t_device type, because invalidate_stack_devices traverses the operand stack looking for devices, and sets their pvalue member to NULL in order to invalidate them so that they cannot be used.
-rw-r--r--psi/zdevice.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/psi/zdevice.c b/psi/zdevice.c
index bd2c542fb..eb6d1b1cf 100644
--- a/psi/zdevice.c
+++ b/psi/zdevice.c
@@ -518,6 +518,9 @@ zsetdevice(i_ctx_t *i_ctx_p)
return code;
check_write_type(*op, t_device);
+ if (op->value.pdevice == 0)
+ return gs_note_error(gs_error_undefined);
+
/* slightly icky special case: the new device may not have had
* it's procs initialised, at this point - but we need to check
* whether we're being asked to change the device here
@@ -537,9 +540,6 @@ zsetdevice(i_ctx_t *i_ctx_p)
}
dev->ShowpageCount = 0;
- if (op->value.pdevice == 0)
- return gs_note_error(gs_error_undefined);
-
code = gs_setdevice_no_erase(igs, op->value.pdevice);
if (code < 0)
return code;