idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
2,300
|
zsetstackprotect(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
ref *ep = oparray_find(i_ctx_p);
check_type(*op, t_boolean);
if (ep == 0)
return_error(gs_error_rangecheck);
ep->value.opproc =
(op->value.boolval ? oparray_cleanup : oparray_no_cleanup);
pop(1);
return 0;
}
| null | 0
|
zsetstackprotect(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
ref *ep = oparray_find(i_ctx_p);
check_type(*op, t_boolean);
if (ep == 0)
return_error(gs_error_rangecheck);
ep->value.opproc =
(op->value.boolval ? oparray_cleanup : oparray_no_cleanup);
pop(1);
return 0;
}
|
@@ -676,7 +676,12 @@ again:
/* Push the error object on the operand stack if appropriate. */
if (!GS_ERROR_IS_INTERRUPT(code)) {
/* Replace the error object if within an oparray or .errorexec. */
- *++osp = *perror_object;
+ osp++;
+ if (osp >= ostop) {
+ *pexit_code = gs_error_Fatal;
+ return_error(gs_error_Fatal);
+ }
+ *osp = *perror_object;
errorexec_find(i_ctx_p, osp);
}
goto again;
|
CWE-388
| null | null |
2,301
|
extend_path_list_container (gs_main_instance * minst, gs_file_path * pfp)
{
uint len = r_size(&minst->lib_path.container);
ref *paths, *opaths = minst->lib_path.container.value.refs;
/* Add 5 entries at a time to reduce VM thrashing */
paths = (ref *) gs_alloc_byte_array(minst->heap, len + LIB_PATH_EXTEND, sizeof(ref),
"extend_path_list_container array");
if (paths == 0) {
return_error(gs_error_VMerror);
}
make_array(&minst->lib_path.container, avm_foreign, len + LIB_PATH_EXTEND, paths);
make_array(&minst->lib_path.list, avm_foreign | a_readonly, 0,
minst->lib_path.container.value.refs);
memcpy(paths, opaths, len * sizeof(ref));
r_set_size(&minst->lib_path.list, len);
gs_free_object (minst->heap, opaths, "extend_path_list_container");
return(0);
}
| null | 0
|
extend_path_list_container (gs_main_instance * minst, gs_file_path * pfp)
{
uint len = r_size(&minst->lib_path.container);
ref *paths, *opaths = minst->lib_path.container.value.refs;
/* Add 5 entries at a time to reduce VM thrashing */
paths = (ref *) gs_alloc_byte_array(minst->heap, len + LIB_PATH_EXTEND, sizeof(ref),
"extend_path_list_container array");
if (paths == 0) {
return_error(gs_error_VMerror);
}
make_array(&minst->lib_path.container, avm_foreign, len + LIB_PATH_EXTEND, paths);
make_array(&minst->lib_path.list, avm_foreign | a_readonly, 0,
minst->lib_path.container.value.refs);
memcpy(paths, opaths, len * sizeof(ref));
r_set_size(&minst->lib_path.list, len);
gs_free_object (minst->heap, opaths, "extend_path_list_container");
return(0);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,302
|
file_path_add(gs_main_instance * minst, gs_file_path * pfp, const char *dirs)
{
uint len = r_size(&pfp->list);
const char *dpath = dirs;
int code;
if (dirs == 0)
return 0;
for (;;) { /* Find the end of the next directory name. */
const char *npath = dpath;
while (*npath != 0 && *npath != gp_file_name_list_separator)
npath++;
if (npath > dpath) {
if (len == r_size(&pfp->container)) {
code = extend_path_list_container(minst, pfp);
if (code < 0) {
emprintf(minst->heap, "\nAdding path to search paths failed.\n");
return(code);
}
}
make_const_string(&pfp->container.value.refs[len],
avm_foreign | a_readonly,
npath - dpath, (const byte *)dpath);
++len;
}
if (!*npath)
break;
dpath = npath + 1;
}
r_set_size(&pfp->list, len);
return 0;
}
| null | 0
|
file_path_add(gs_main_instance * minst, gs_file_path * pfp, const char *dirs)
{
uint len = r_size(&pfp->list);
const char *dpath = dirs;
int code;
if (dirs == 0)
return 0;
for (;;) { /* Find the end of the next directory name. */
const char *npath = dpath;
while (*npath != 0 && *npath != gp_file_name_list_separator)
npath++;
if (npath > dpath) {
if (len == r_size(&pfp->container)) {
code = extend_path_list_container(minst, pfp);
if (code < 0) {
emprintf(minst->heap, "\nAdding path to search paths failed.\n");
return(code);
}
}
make_const_string(&pfp->container.value.refs[len],
avm_foreign | a_readonly,
npath - dpath, (const byte *)dpath);
++len;
}
if (!*npath)
break;
dpath = npath + 1;
}
r_set_size(&pfp->list, len);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,303
|
get_global_op_array(const gs_memory_t *mem)
{
gs_main_instance *minst = get_minst_from_memory(mem);
return &minst->i_ctx_p->op_array_table_global;
}
| null | 0
|
get_global_op_array(const gs_memory_t *mem)
{
gs_main_instance *minst = get_minst_from_memory(mem);
return &minst->i_ctx_p->op_array_table_global;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,304
|
get_minst_from_memory(const gs_memory_t *mem)
{
return (gs_main_instance*)mem->gs_lib_ctx->top_of_system;
}
| null | 0
|
get_minst_from_memory(const gs_memory_t *mem)
{
return (gs_main_instance*)mem->gs_lib_ctx->top_of_system;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,305
|
get_op_array(const gs_memory_t *mem, int size)
{
gs_main_instance *minst = get_minst_from_memory(mem);
return op_index_op_array_table(minst->i_ctx_p,size);
}
| null | 0
|
get_op_array(const gs_memory_t *mem, int size)
{
gs_main_instance *minst = get_minst_from_memory(mem);
return op_index_op_array_table(minst->i_ctx_p,size);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,306
|
gs_abort(const gs_memory_t *mem)
{
/* In previous versions, we tried to do a cleanup (using gs_to_exit),
* but more often than not, that will trip another abort and create
* an infinite recursion. So just abort without trying to cleanup.
*/
gp_do_exit(1);
}
| null | 0
|
gs_abort(const gs_memory_t *mem)
{
/* In previous versions, we tried to do a cleanup (using gs_to_exit),
* but more often than not, that will trip another abort and create
* an infinite recursion. So just abort without trying to cleanup.
*/
gp_do_exit(1);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,307
|
gs_finit_push_systemdict(i_ctx_t *i_ctx_p)
{
if (i_ctx_p == NULL)
return;
if (dsp == dstop ) {
if (ref_stack_extend(&d_stack, 1) < 0) {
/* zend() cannot fail */
(void)zend(i_ctx_p);
}
}
dsp++;
ref_assign(dsp, systemdict);
}
| null | 0
|
gs_finit_push_systemdict(i_ctx_t *i_ctx_p)
{
if (i_ctx_p == NULL)
return;
if (dsp == dstop ) {
if (ref_stack_extend(&d_stack, 1) < 0) {
/* zend() cannot fail */
(void)zend(i_ctx_p);
}
}
dsp++;
ref_assign(dsp, systemdict);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,308
|
gs_main_dump_stack(gs_main_instance *minst, int code, ref * perror_object)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
zflush(i_ctx_p); /* force out buffered output */
dmprintf1(minst->heap, "\nUnexpected interpreter error %d.\n", code);
if (perror_object != 0) {
dmputs(minst->heap, "Error object: ");
debug_print_ref(minst->heap, perror_object);
dmputc(minst->heap, '\n');
}
debug_dump_stack(minst->heap, &o_stack, "Operand stack");
debug_dump_stack(minst->heap, &e_stack, "Execution stack");
debug_dump_stack(minst->heap, &d_stack, "Dictionary stack");
}
| null | 0
|
gs_main_dump_stack(gs_main_instance *minst, int code, ref * perror_object)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
zflush(i_ctx_p); /* force out buffered output */
dmprintf1(minst->heap, "\nUnexpected interpreter error %d.\n", code);
if (perror_object != 0) {
dmputs(minst->heap, "Error object: ");
debug_print_ref(minst->heap, perror_object);
dmputc(minst->heap, '\n');
}
debug_dump_stack(minst->heap, &o_stack, "Operand stack");
debug_dump_stack(minst->heap, &e_stack, "Execution stack");
debug_dump_stack(minst->heap, &d_stack, "Dictionary stack");
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,309
|
gs_main_init0(gs_main_instance * minst, FILE * in, FILE * out, FILE * err,
int max_lib_paths)
{
ref *array;
/* Do platform-dependent initialization. */
/* We have to do this as the very first thing, */
/* because it detects attempts to run 80N86 executables (N>0) */
/* on incompatible processors. */
gp_init();
/* Initialize the imager. */
/* Reset debugging flags */
#ifdef PACIFY_VALGRIND
VALGRIND_HG_DISABLE_CHECKING(gs_debug, 128);
#endif
memset(gs_debug, 0, 128);
gs_log_errors = 0; /* gs_debug['#'] = 0 */
gp_get_realtime(minst->base_time);
/* Initialize the file search paths. */
array = (ref *) gs_alloc_byte_array(minst->heap, max_lib_paths, sizeof(ref),
"lib_path array");
if (array == 0) {
gs_lib_finit(1, gs_error_VMerror, minst->heap);
return_error(gs_error_VMerror);
}
make_array(&minst->lib_path.container, avm_foreign, max_lib_paths,
array);
make_array(&minst->lib_path.list, avm_foreign | a_readonly, 0,
minst->lib_path.container.value.refs);
minst->lib_path.env = 0;
minst->lib_path.final = 0;
minst->lib_path.count = 0;
minst->user_errors = 1;
minst->init_done = 0;
return 0;
}
| null | 0
|
gs_main_init0(gs_main_instance * minst, FILE * in, FILE * out, FILE * err,
int max_lib_paths)
{
ref *array;
/* Do platform-dependent initialization. */
/* We have to do this as the very first thing, */
/* because it detects attempts to run 80N86 executables (N>0) */
/* on incompatible processors. */
gp_init();
/* Initialize the imager. */
/* Reset debugging flags */
#ifdef PACIFY_VALGRIND
VALGRIND_HG_DISABLE_CHECKING(gs_debug, 128);
#endif
memset(gs_debug, 0, 128);
gs_log_errors = 0; /* gs_debug['#'] = 0 */
gp_get_realtime(minst->base_time);
/* Initialize the file search paths. */
array = (ref *) gs_alloc_byte_array(minst->heap, max_lib_paths, sizeof(ref),
"lib_path array");
if (array == 0) {
gs_lib_finit(1, gs_error_VMerror, minst->heap);
return_error(gs_error_VMerror);
}
make_array(&minst->lib_path.container, avm_foreign, max_lib_paths,
array);
make_array(&minst->lib_path.list, avm_foreign | a_readonly, 0,
minst->lib_path.container.value.refs);
minst->lib_path.env = 0;
minst->lib_path.final = 0;
minst->lib_path.count = 0;
minst->user_errors = 1;
minst->init_done = 0;
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,310
|
gs_main_init1(gs_main_instance * minst)
{
gs_dual_memory_t idmem;
name_table *nt = NULL;
int code = 0;
if (minst->init_done < 1) {
code = ialloc_init(&idmem, minst->heap,
minst->memory_clump_size, gs_have_level2());
if (code < 0)
return code;
code = gs_lib_init1((gs_memory_t *)idmem.space_system);
if (code < 0)
goto fail;
alloc_save_init(&idmem);
{
gs_memory_t *mem = (gs_memory_t *)idmem.space_system;
nt = names_init(minst->name_table_size, idmem.space_system);
if (nt == 0) {
code = gs_note_error(gs_error_VMerror);
goto fail;
}
mem->gs_lib_ctx->gs_name_table = nt;
code = gs_register_struct_root(mem, mem->gs_lib_ctx->name_table_root,
(void **)&mem->gs_lib_ctx->gs_name_table,
"the_gs_name_table");
if (code < 0)
goto fail;
mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions;
}
code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */
if (code < 0)
goto fail;
minst->init_done = 1;
code = i_plugin_init(minst->i_ctx_p);
if (code < 0)
goto fail;
code = i_iodev_init(&idmem);
if (code < 0)
goto fail;
}
return 0;
fail:
names_free(nt);
if (minst->i_ctx_p == NULL)
ialloc_finit(&idmem);
return code;
}
| null | 0
|
gs_main_init1(gs_main_instance * minst)
{
gs_dual_memory_t idmem;
name_table *nt = NULL;
int code = 0;
if (minst->init_done < 1) {
code = ialloc_init(&idmem, minst->heap,
minst->memory_clump_size, gs_have_level2());
if (code < 0)
return code;
code = gs_lib_init1((gs_memory_t *)idmem.space_system);
if (code < 0)
goto fail;
alloc_save_init(&idmem);
{
gs_memory_t *mem = (gs_memory_t *)idmem.space_system;
nt = names_init(minst->name_table_size, idmem.space_system);
if (nt == 0) {
code = gs_note_error(gs_error_VMerror);
goto fail;
}
mem->gs_lib_ctx->gs_name_table = nt;
code = gs_register_struct_root(mem, mem->gs_lib_ctx->name_table_root,
(void **)&mem->gs_lib_ctx->gs_name_table,
"the_gs_name_table");
if (code < 0)
goto fail;
mem->gs_lib_ctx->client_check_file_permission = z_check_file_permissions;
}
code = obj_init(&minst->i_ctx_p, &idmem); /* requires name_init */
if (code < 0)
goto fail;
minst->init_done = 1;
code = i_plugin_init(minst->i_ctx_p);
if (code < 0)
goto fail;
code = i_iodev_init(&idmem);
if (code < 0)
goto fail;
}
return 0;
fail:
names_free(nt);
if (minst->i_ctx_p == NULL)
ialloc_finit(&idmem);
return code;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,311
|
gs_main_init2(gs_main_instance * minst)
{
i_ctx_t *i_ctx_p;
int code = gs_main_init1(minst);
int initial_init_level = minst->init_done;
if (code < 0)
return code;
code = gs_main_init2aux(minst);
if (code < 0)
return code;
i_ctx_p = minst->i_ctx_p; /* display_set_callback or run_string may change it */
/* Now process the initial saved-pages=... argument, if any as well as saved-pages-test */
if (initial_init_level < 2) {
gx_device *pdev = gs_currentdevice(minst->i_ctx_p->pgs); /* get the current device */
gx_device_printer *ppdev = (gx_device_printer *)pdev;
if (minst->saved_pages_test_mode) {
if ((dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) <= 0)) {
/* no warning or error if saved-pages-test mode is used, just disable it */
minst->saved_pages_test_mode = false; /* device doesn't support it */
} else {
if ((code = gx_saved_pages_param_process(ppdev, (byte *)"begin", 5)) < 0)
return code;
if (code > 0)
if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0)
return code;
}
} else if (minst->saved_pages_initial_arg != NULL) {
if (dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) <= 0) {
outprintf(minst->heap,
" --saved-pages not supported by the '%s' device.\n",
pdev->dname);
return gs_error_Fatal;
}
code = gx_saved_pages_param_process(ppdev, (byte *)minst->saved_pages_initial_arg,
strlen(minst->saved_pages_initial_arg));
if (code > 0)
if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0)
return code;
}
}
if (gs_debug_c(':'))
print_resource_usage(minst, &gs_imemory, "Start");
gp_readline_init(&minst->readline_data, imemory_system);
return 0;
}
| null | 0
|
gs_main_init2(gs_main_instance * minst)
{
i_ctx_t *i_ctx_p;
int code = gs_main_init1(minst);
int initial_init_level = minst->init_done;
if (code < 0)
return code;
code = gs_main_init2aux(minst);
if (code < 0)
return code;
i_ctx_p = minst->i_ctx_p; /* display_set_callback or run_string may change it */
/* Now process the initial saved-pages=... argument, if any as well as saved-pages-test */
if (initial_init_level < 2) {
gx_device *pdev = gs_currentdevice(minst->i_ctx_p->pgs); /* get the current device */
gx_device_printer *ppdev = (gx_device_printer *)pdev;
if (minst->saved_pages_test_mode) {
if ((dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) <= 0)) {
/* no warning or error if saved-pages-test mode is used, just disable it */
minst->saved_pages_test_mode = false; /* device doesn't support it */
} else {
if ((code = gx_saved_pages_param_process(ppdev, (byte *)"begin", 5)) < 0)
return code;
if (code > 0)
if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0)
return code;
}
} else if (minst->saved_pages_initial_arg != NULL) {
if (dev_proc(pdev, dev_spec_op)(pdev, gxdso_supports_saved_pages, NULL, 0) <= 0) {
outprintf(minst->heap,
" --saved-pages not supported by the '%s' device.\n",
pdev->dname);
return gs_error_Fatal;
}
code = gx_saved_pages_param_process(ppdev, (byte *)minst->saved_pages_initial_arg,
strlen(minst->saved_pages_initial_arg));
if (code > 0)
if ((code = gs_erasepage(minst->i_ctx_p->pgs)) < 0)
return code;
}
}
if (gs_debug_c(':'))
print_resource_usage(minst, &gs_imemory, "Start");
gp_readline_init(&minst->readline_data, imemory_system);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,312
|
int gs_main_init2aux(gs_main_instance * minst) {
i_ctx_t * i_ctx_p = minst->i_ctx_p;
if (minst->init_done < 2) {
int code, exit_code;
ref error_object, ifa;
/* Set up enough so that we can safely be garbage collected */
i_ctx_p->op_array_table_global = empty_table;
i_ctx_p->op_array_table_local = empty_table;
code = zop_init(i_ctx_p);
if (code < 0)
return code;
code = op_init(i_ctx_p); /* requires obj_init */
if (code < 0)
return code;
/* Set up the array of additional initialization files. */
make_const_string(&ifa, a_readonly | avm_foreign, gs_init_files_sizeof - 2, gs_init_files);
code = initial_enter_name("INITFILES", &ifa);
if (code < 0)
return code;
/* Set up the array of emulator names. */
make_const_string(&ifa, a_readonly | avm_foreign, gs_emulators_sizeof - 2, gs_emulators);
code = initial_enter_name("EMULATORS", &ifa);
if (code < 0)
return code;
/* Pass the search path. */
code = initial_enter_name("LIBPATH", &minst->lib_path.list);
if (code < 0)
return code;
/* Execute the standard initialization file. */
code = gs_run_init_file(minst, &exit_code, &error_object);
if (code < 0)
return code;
minst->init_done = 2;
/* NB this is to be done with device parameters
* both minst->display and display_set_callback() are going away
*/
if (minst->display)
if ((code = display_set_callback(minst, minst->display)) < 0)
return code;
if ((code = gs_main_run_string(minst,
"JOBSERVER "
" { false 0 .startnewjob } "
" { NOOUTERSAVE not { save pop } if } "
"ifelse", 0, &exit_code,
&error_object)) < 0)
return code;
}
return 0;
}
| null | 0
|
int gs_main_init2aux(gs_main_instance * minst) {
i_ctx_t * i_ctx_p = minst->i_ctx_p;
if (minst->init_done < 2) {
int code, exit_code;
ref error_object, ifa;
/* Set up enough so that we can safely be garbage collected */
i_ctx_p->op_array_table_global = empty_table;
i_ctx_p->op_array_table_local = empty_table;
code = zop_init(i_ctx_p);
if (code < 0)
return code;
code = op_init(i_ctx_p); /* requires obj_init */
if (code < 0)
return code;
/* Set up the array of additional initialization files. */
make_const_string(&ifa, a_readonly | avm_foreign, gs_init_files_sizeof - 2, gs_init_files);
code = initial_enter_name("INITFILES", &ifa);
if (code < 0)
return code;
/* Set up the array of emulator names. */
make_const_string(&ifa, a_readonly | avm_foreign, gs_emulators_sizeof - 2, gs_emulators);
code = initial_enter_name("EMULATORS", &ifa);
if (code < 0)
return code;
/* Pass the search path. */
code = initial_enter_name("LIBPATH", &minst->lib_path.list);
if (code < 0)
return code;
/* Execute the standard initialization file. */
code = gs_run_init_file(minst, &exit_code, &error_object);
if (code < 0)
return code;
minst->init_done = 2;
/* NB this is to be done with device parameters
* both minst->display and display_set_callback() are going away
*/
if (minst->display)
if ((code = display_set_callback(minst, minst->display)) < 0)
return code;
if ((code = gs_main_run_string(minst,
"JOBSERVER "
" { false 0 .startnewjob } "
" { NOOUTERSAVE not { save pop } if } "
"ifelse", 0, &exit_code,
&error_object)) < 0)
return code;
}
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,313
|
gs_main_interpret(gs_main_instance *minst, ref * pref, int user_errors,
int *pexit_code, ref * perror_object)
{
int code;
/* set interpreter pointer to lib_path */
minst->i_ctx_p->lib_path = &minst->lib_path;
code = gs_interpret(&minst->i_ctx_p, pref,
user_errors, pexit_code, perror_object);
return code;
}
| null | 0
|
gs_main_interpret(gs_main_instance *minst, ref * pref, int user_errors,
int *pexit_code, ref * perror_object)
{
int code;
/* set interpreter pointer to lib_path */
minst->i_ctx_p->lib_path = &minst->lib_path;
code = gs_interpret(&minst->i_ctx_p, pref,
user_errors, pexit_code, perror_object);
return code;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,314
|
gs_main_lib_open(gs_main_instance * minst, const char *file_name, ref * pfile)
{
/* This is a separate procedure only to avoid tying up */
/* extra stack space while running the file. */
i_ctx_t *i_ctx_p = minst->i_ctx_p;
#define maxfn 2048
char fn[maxfn];
uint len;
return lib_file_open(&minst->lib_path, imemory,
NULL, /* Don't check permissions here, because permlist
isn't ready running init files. */
file_name, strlen(file_name), fn, maxfn, &len, pfile);
}
| null | 0
|
gs_main_lib_open(gs_main_instance * minst, const char *file_name, ref * pfile)
{
/* This is a separate procedure only to avoid tying up */
/* extra stack space while running the file. */
i_ctx_t *i_ctx_p = minst->i_ctx_p;
#define maxfn 2048
char fn[maxfn];
uint len;
return lib_file_open(&minst->lib_path, imemory,
NULL, /* Don't check permissions here, because permlist
isn't ready running init files. */
file_name, strlen(file_name), fn, maxfn, &len, pfile);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,315
|
gs_main_run_file(gs_main_instance * minst, const char *file_name, int user_errors, int *pexit_code, ref * perror_object)
{
ref initial_file;
int code = gs_main_run_file_open(minst, file_name, &initial_file);
if (code < 0)
return code;
return gs_main_interpret(minst, &initial_file, user_errors,
pexit_code, perror_object);
}
| null | 0
|
gs_main_run_file(gs_main_instance * minst, const char *file_name, int user_errors, int *pexit_code, ref * perror_object)
{
ref initial_file;
int code = gs_main_run_file_open(minst, file_name, &initial_file);
if (code < 0)
return code;
return gs_main_interpret(minst, &initial_file, user_errors,
pexit_code, perror_object);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,316
|
gs_main_run_file_open(gs_main_instance * minst, const char *file_name, ref * pfref)
{
gs_main_set_lib_paths(minst);
if (gs_main_lib_open(minst, file_name, pfref) < 0) {
emprintf1(minst->heap,
"Can't find initialization file %s.\n",
file_name);
return_error(gs_error_Fatal);
}
r_set_attrs(pfref, a_execute + a_executable);
return 0;
}
| null | 0
|
gs_main_run_file_open(gs_main_instance * minst, const char *file_name, ref * pfref)
{
gs_main_set_lib_paths(minst);
if (gs_main_lib_open(minst, file_name, pfref) < 0) {
emprintf1(minst->heap,
"Can't find initialization file %s.\n",
file_name);
return_error(gs_error_Fatal);
}
r_set_attrs(pfref, a_execute + a_executable);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,317
|
gs_main_run_string(gs_main_instance * minst, const char *str, int user_errors,
int *pexit_code, ref * perror_object)
{
return gs_main_run_string_with_length(minst, str, (uint) strlen(str),
user_errors,
pexit_code, perror_object);
}
| null | 0
|
gs_main_run_string(gs_main_instance * minst, const char *str, int user_errors,
int *pexit_code, ref * perror_object)
{
return gs_main_run_string_with_length(minst, str, (uint) strlen(str),
user_errors,
pexit_code, perror_object);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,318
|
gs_main_run_string_begin(gs_main_instance * minst, int user_errors,
int *pexit_code, ref * perror_object)
{
const char *setup = ".runstringbegin";
ref rstr;
int code;
gs_main_set_lib_paths(minst);
make_const_string(&rstr, avm_foreign | a_readonly | a_executable,
strlen(setup), (const byte *)setup);
code = gs_main_interpret(minst, &rstr, user_errors, pexit_code,
perror_object);
return (code == gs_error_NeedInput ? 0 : code == 0 ? gs_error_Fatal : code);
}
| null | 0
|
gs_main_run_string_begin(gs_main_instance * minst, int user_errors,
int *pexit_code, ref * perror_object)
{
const char *setup = ".runstringbegin";
ref rstr;
int code;
gs_main_set_lib_paths(minst);
make_const_string(&rstr, avm_foreign | a_readonly | a_executable,
strlen(setup), (const byte *)setup);
code = gs_main_interpret(minst, &rstr, user_errors, pexit_code,
perror_object);
return (code == gs_error_NeedInput ? 0 : code == 0 ? gs_error_Fatal : code);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,319
|
gs_main_run_string_continue(gs_main_instance * minst, const char *str,
uint length, int user_errors, int *pexit_code, ref * perror_object)
{
ref rstr;
if (length == 0)
return 0; /* empty string signals EOF */
make_const_string(&rstr, avm_foreign | a_readonly, length,
(const byte *)str);
return gs_main_interpret(minst, &rstr, user_errors, pexit_code,
perror_object);
}
| null | 0
|
gs_main_run_string_continue(gs_main_instance * minst, const char *str,
uint length, int user_errors, int *pexit_code, ref * perror_object)
{
ref rstr;
if (length == 0)
return 0; /* empty string signals EOF */
make_const_string(&rstr, avm_foreign | a_readonly, length,
(const byte *)str);
return gs_main_interpret(minst, &rstr, user_errors, pexit_code,
perror_object);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,320
|
gs_main_run_string_with_length(gs_main_instance * minst, const char *str,
uint length, int user_errors, int *pexit_code, ref * perror_object)
{
int code;
code = gs_main_run_string_begin(minst, user_errors,
pexit_code, perror_object);
if (code < 0)
return code;
code = gs_main_run_string_continue(minst, str, length, user_errors,
pexit_code, perror_object);
if (code != gs_error_NeedInput)
return code;
return gs_main_run_string_end(minst, user_errors,
pexit_code, perror_object);
}
| null | 0
|
gs_main_run_string_with_length(gs_main_instance * minst, const char *str,
uint length, int user_errors, int *pexit_code, ref * perror_object)
{
int code;
code = gs_main_run_string_begin(minst, user_errors,
pexit_code, perror_object);
if (code < 0)
return code;
code = gs_main_run_string_continue(minst, str, length, user_errors,
pexit_code, perror_object);
if (code != gs_error_NeedInput)
return code;
return gs_main_run_string_end(minst, user_errors,
pexit_code, perror_object);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,321
|
gs_main_set_lib_paths(gs_main_instance * minst)
{
ref *paths = minst->lib_path.container.value.refs;
int first_is_here =
(r_size(&minst->lib_path.list) != 0 &&
paths[0].value.bytes == (const byte *)gp_current_directory_name ? 1 : 0);
int code = 0;
int count = minst->lib_path.count;
int i, have_rom_device = 0;
if (minst->search_here_first) {
if (!(first_is_here ||
(r_size(&minst->lib_path.list) != 0 &&
!bytes_compare((const byte *)gp_current_directory_name,
strlen(gp_current_directory_name),
paths[0].value.bytes,
r_size(&paths[0]))))
) {
memmove(paths + 1, paths, count * sizeof(*paths));
make_const_string(paths, avm_foreign | a_readonly,
strlen(gp_current_directory_name),
(const byte *)gp_current_directory_name);
}
} else {
if (first_is_here)
memmove(paths, paths + 1, count * sizeof(*paths));
}
r_set_size(&minst->lib_path.list,
count + (minst->search_here_first ? 1 : 0));
if (minst->lib_path.env != 0)
code = file_path_add(minst, &minst->lib_path, minst->lib_path.env);
/* now put the %rom%lib/ device path before the gs_lib_default_path on the list */
for (i = 0; i < gx_io_device_table_count; i++) {
const gx_io_device *iodev = gx_io_device_table[i];
const char *dname = iodev->dname;
if (dname && strlen(dname) == 5 && !memcmp("%rom%", dname, 5)) {
struct stat pstat;
/* gs_error_unregistered means no usable romfs is available */
int code = iodev->procs.file_status((gx_io_device *)iodev, dname, &pstat);
if (code != gs_error_unregistered){
have_rom_device = 1;
}
break;
}
}
if (have_rom_device && code >= 0) {
code = file_path_add(minst, &minst->lib_path, "%rom%Resource/Init/");
if (code < 0)
return code;
code = file_path_add(minst, &minst->lib_path, "%rom%lib/");
}
if (minst->lib_path.final != 0 && code >= 0)
code = file_path_add(minst, &minst->lib_path, minst->lib_path.final);
return code;
}
| null | 0
|
gs_main_set_lib_paths(gs_main_instance * minst)
{
ref *paths = minst->lib_path.container.value.refs;
int first_is_here =
(r_size(&minst->lib_path.list) != 0 &&
paths[0].value.bytes == (const byte *)gp_current_directory_name ? 1 : 0);
int code = 0;
int count = minst->lib_path.count;
int i, have_rom_device = 0;
if (minst->search_here_first) {
if (!(first_is_here ||
(r_size(&minst->lib_path.list) != 0 &&
!bytes_compare((const byte *)gp_current_directory_name,
strlen(gp_current_directory_name),
paths[0].value.bytes,
r_size(&paths[0]))))
) {
memmove(paths + 1, paths, count * sizeof(*paths));
make_const_string(paths, avm_foreign | a_readonly,
strlen(gp_current_directory_name),
(const byte *)gp_current_directory_name);
}
} else {
if (first_is_here)
memmove(paths, paths + 1, count * sizeof(*paths));
}
r_set_size(&minst->lib_path.list,
count + (minst->search_here_first ? 1 : 0));
if (minst->lib_path.env != 0)
code = file_path_add(minst, &minst->lib_path, minst->lib_path.env);
/* now put the %rom%lib/ device path before the gs_lib_default_path on the list */
for (i = 0; i < gx_io_device_table_count; i++) {
const gx_io_device *iodev = gx_io_device_table[i];
const char *dname = iodev->dname;
if (dname && strlen(dname) == 5 && !memcmp("%rom%", dname, 5)) {
struct stat pstat;
/* gs_error_unregistered means no usable romfs is available */
int code = iodev->procs.file_status((gx_io_device *)iodev, dname, &pstat);
if (code != gs_error_unregistered){
have_rom_device = 1;
}
break;
}
}
if (have_rom_device && code >= 0) {
code = file_path_add(minst, &minst->lib_path, "%rom%Resource/Init/");
if (code < 0)
return code;
code = file_path_add(minst, &minst->lib_path, "%rom%lib/");
}
if (minst->lib_path.final != 0 && code >= 0)
code = file_path_add(minst, &minst->lib_path, minst->lib_path.final);
return code;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,322
|
static char *gs_main_tempnames(gs_main_instance *minst)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref *SAFETY;
ref *tempfiles;
ref keyval[2]; /* for key and value */
char *tempnames = NULL;
int i;
int idict;
int len = 0;
const byte *data = NULL;
uint size;
if (minst->init_done >= 2) {
if (dict_find_string(systemdict, "SAFETY", &SAFETY) <= 0 ||
dict_find_string(SAFETY, "tempfiles", &tempfiles) <= 0)
return NULL;
/* get lengths of temporary filenames */
idict = dict_first(tempfiles);
while ((idict = dict_next(tempfiles, idict, &keyval[0])) >= 0) {
if (obj_string_data(minst->heap, &keyval[0], &data, &size) >= 0)
len += size + 1;
}
if (len != 0)
tempnames = (char *)malloc(len+1);
if (tempnames) {
memset(tempnames, 0, len+1);
/* copy temporary filenames */
idict = dict_first(tempfiles);
i = 0;
while ((idict = dict_next(tempfiles, idict, &keyval[0])) >= 0) {
if (obj_string_data(minst->heap, &keyval[0], &data, &size) >= 0) {
memcpy(tempnames+i, (const char *)data, size);
i+= size;
tempnames[i++] = '\0';
}
}
}
}
return tempnames;
}
| null | 0
|
static char *gs_main_tempnames(gs_main_instance *minst)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref *SAFETY;
ref *tempfiles;
ref keyval[2]; /* for key and value */
char *tempnames = NULL;
int i;
int idict;
int len = 0;
const byte *data = NULL;
uint size;
if (minst->init_done >= 2) {
if (dict_find_string(systemdict, "SAFETY", &SAFETY) <= 0 ||
dict_find_string(SAFETY, "tempfiles", &tempfiles) <= 0)
return NULL;
/* get lengths of temporary filenames */
idict = dict_first(tempfiles);
while ((idict = dict_next(tempfiles, idict, &keyval[0])) >= 0) {
if (obj_string_data(minst->heap, &keyval[0], &data, &size) >= 0)
len += size + 1;
}
if (len != 0)
tempnames = (char *)malloc(len+1);
if (tempnames) {
memset(tempnames, 0, len+1);
/* copy temporary filenames */
idict = dict_first(tempfiles);
i = 0;
while ((idict = dict_next(tempfiles, idict, &keyval[0])) >= 0) {
if (obj_string_data(minst->heap, &keyval[0], &data, &size) >= 0) {
memcpy(tempnames+i, (const char *)data, size);
i+= size;
tempnames[i++] = '\0';
}
}
}
}
return tempnames;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,323
|
gs_pop_boolean(gs_main_instance * minst, bool * result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
check_type_only(vref, t_boolean);
*result = vref.value.boolval;
ref_stack_pop(&o_stack, 1);
return 0;
}
| null | 0
|
gs_pop_boolean(gs_main_instance * minst, bool * result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
check_type_only(vref, t_boolean);
*result = vref.value.boolval;
ref_stack_pop(&o_stack, 1);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,324
|
gs_pop_integer(gs_main_instance * minst, long *result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
check_type_only(vref, t_integer);
*result = vref.value.intval;
ref_stack_pop(&o_stack, 1);
return 0;
}
| null | 0
|
gs_pop_integer(gs_main_instance * minst, long *result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
check_type_only(vref, t_integer);
*result = vref.value.intval;
ref_stack_pop(&o_stack, 1);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,325
|
gs_pop_real(gs_main_instance * minst, float *result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
switch (r_type(&vref)) {
case t_real:
*result = vref.value.realval;
break;
case t_integer:
*result = (float)(vref.value.intval);
break;
default:
return_error(gs_error_typecheck);
}
ref_stack_pop(&o_stack, 1);
return 0;
}
| null | 0
|
gs_pop_real(gs_main_instance * minst, float *result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
switch (r_type(&vref)) {
case t_real:
*result = vref.value.realval;
break;
case t_integer:
*result = (float)(vref.value.intval);
break;
default:
return_error(gs_error_typecheck);
}
ref_stack_pop(&o_stack, 1);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,326
|
gs_pop_string(gs_main_instance * minst, gs_string * result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
switch (r_type(&vref)) {
case t_name:
name_string_ref(minst->heap, &vref, &vref);
code = 1;
goto rstr;
case t_string:
code = (r_has_attr(&vref, a_write) ? 0 : 1);
rstr:result->data = vref.value.bytes;
result->size = r_size(&vref);
break;
default:
return_error(gs_error_typecheck);
}
ref_stack_pop(&o_stack, 1);
return code;
}
| null | 0
|
gs_pop_string(gs_main_instance * minst, gs_string * result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
switch (r_type(&vref)) {
case t_name:
name_string_ref(minst->heap, &vref, &vref);
code = 1;
goto rstr;
case t_string:
code = (r_has_attr(&vref, a_write) ? 0 : 1);
rstr:result->data = vref.value.bytes;
result->size = r_size(&vref);
break;
default:
return_error(gs_error_typecheck);
}
ref_stack_pop(&o_stack, 1);
return code;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,327
|
gs_push_boolean(gs_main_instance * minst, bool value)
{
ref vref;
make_bool(&vref, value);
return push_value(minst, &vref);
}
| null | 0
|
gs_push_boolean(gs_main_instance * minst, bool value)
{
ref vref;
make_bool(&vref, value);
return push_value(minst, &vref);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,328
|
gs_push_integer(gs_main_instance * minst, long value)
{
ref vref;
make_int(&vref, value);
return push_value(minst, &vref);
}
| null | 0
|
gs_push_integer(gs_main_instance * minst, long value)
{
ref vref;
make_int(&vref, value);
return push_value(minst, &vref);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,329
|
gs_push_real(gs_main_instance * minst, double value)
{
ref vref;
make_real(&vref, value);
return push_value(minst, &vref);
}
| null | 0
|
gs_push_real(gs_main_instance * minst, double value)
{
ref vref;
make_real(&vref, value);
return push_value(minst, &vref);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,330
|
gs_push_string(gs_main_instance * minst, byte * chars, uint length,
bool read_only)
{
ref vref;
make_string(&vref, avm_foreign | (read_only ? a_readonly : a_all),
length, (byte *) chars);
return push_value(minst, &vref);
}
| null | 0
|
gs_push_string(gs_main_instance * minst, byte * chars, uint length,
bool read_only)
{
ref vref;
make_string(&vref, avm_foreign | (read_only ? a_readonly : a_all),
length, (byte *) chars);
return push_value(minst, &vref);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,331
|
pop_value(i_ctx_t *i_ctx_p, ref * pvalue)
{
if (!ref_stack_count(&o_stack))
return_error(gs_error_stackunderflow);
*pvalue = *ref_stack_index(&o_stack, 0L);
return 0;
}
| null | 0
|
pop_value(i_ctx_t *i_ctx_p, ref * pvalue)
{
if (!ref_stack_count(&o_stack))
return_error(gs_error_stackunderflow);
*pvalue = *ref_stack_index(&o_stack, 0L);
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,332
|
print_resource_usage(const gs_main_instance * minst, gs_dual_memory_t * dmem,
const char *msg)
{
ulong used = 0; /* this we accumulate for the PS memories */
long utime[2];
int i;
gs_memory_status_t status;
gp_get_realtime(utime);
for (i = 0; i < countof(dmem->spaces_indexed); ++i) {
gs_ref_memory_t *mem = dmem->spaces_indexed[i];
if (mem != 0 && (i == 0 || mem != dmem->spaces_indexed[i - 1])) {
gs_ref_memory_t *mem_stable =
(gs_ref_memory_t *)gs_memory_stable((gs_memory_t *)mem);
gs_memory_status((gs_memory_t *)mem, &status);
used += status.used;
if (mem_stable != mem) {
gs_memory_status((gs_memory_t *)mem_stable, &status);
used += status.used;
}
}
}
/* Now get the overall values from the heap memory */
gs_memory_status(minst->heap, &status);
dmprintf5(minst->heap, "%% %s time = %g, memory allocated = %lu, used = %lu, max_used = %lu\n",
msg, utime[0] - minst->base_time[0] +
(utime[1] - minst->base_time[1]) / 1000000000.0,
status.allocated, used, status.max_used);
}
| null | 0
|
print_resource_usage(const gs_main_instance * minst, gs_dual_memory_t * dmem,
const char *msg)
{
ulong used = 0; /* this we accumulate for the PS memories */
long utime[2];
int i;
gs_memory_status_t status;
gp_get_realtime(utime);
for (i = 0; i < countof(dmem->spaces_indexed); ++i) {
gs_ref_memory_t *mem = dmem->spaces_indexed[i];
if (mem != 0 && (i == 0 || mem != dmem->spaces_indexed[i - 1])) {
gs_ref_memory_t *mem_stable =
(gs_ref_memory_t *)gs_memory_stable((gs_memory_t *)mem);
gs_memory_status((gs_memory_t *)mem, &status);
used += status.used;
if (mem_stable != mem) {
gs_memory_status((gs_memory_t *)mem_stable, &status);
used += status.used;
}
}
}
/* Now get the overall values from the heap memory */
gs_memory_status(minst->heap, &status);
dmprintf5(minst->heap, "%% %s time = %g, memory allocated = %lu, used = %lu, max_used = %lu\n",
msg, utime[0] - minst->base_time[0] +
(utime[1] - minst->base_time[1]) / 1000000000.0,
status.allocated, used, status.max_used);
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,333
|
push_value(gs_main_instance *minst, ref * pvalue)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
int code = ref_stack_push(&o_stack, 1);
if (code < 0)
return code;
*ref_stack_index(&o_stack, 0L) = *pvalue;
return 0;
}
| null | 0
|
push_value(gs_main_instance *minst, ref * pvalue)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
int code = ref_stack_push(&o_stack, 1);
if (code < 0)
return code;
*ref_stack_index(&o_stack, 0L) = *pvalue;
return 0;
}
|
@@ -936,6 +936,16 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* interp_reclaim could change it. */
}
+ if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL &&
+ gx_device_is_null(i_ctx_p->pgs->device)) {
+ /* if the job replaced the device with the nulldevice, we we need to grestore
+ away that device, so the block below can properly dispense
+ with the default device.
+ */
+ int code = gs_grestoreall(i_ctx_p->pgs);
+ if (code < 0) return_error(gs_error_Fatal);
+ }
+
if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
gx_device *pdev = i_ctx_p->pgs->device;
const char * dname = pdev->dname;
|
CWE-416
| null | null |
2,334
|
ENUM_PTRS_WITH(pdf14_device_enum_ptrs, pdf14_device *pdev)
{
index -= 5;
if (index < pdev->devn_params.separations.num_separations)
ENUM_RETURN(pdev->devn_params.separations.names[index].data);
index -= pdev->devn_params.separations.num_separations;
if (index < pdev->devn_params.pdf14_separations.num_separations)
ENUM_RETURN(pdev->devn_params.pdf14_separations.names[index].data);
return 0;
}
| null | 0
|
ENUM_PTRS_WITH(pdf14_device_enum_ptrs, pdf14_device *pdev)
{
index -= 5;
if (index < pdev->devn_params.separations.num_separations)
ENUM_RETURN(pdev->devn_params.separations.names[index].data);
index -= pdev->devn_params.separations.num_separations;
if (index < pdev->devn_params.pdf14_separations.num_separations)
ENUM_RETURN(pdev->devn_params.pdf14_separations.names[index].data);
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,335
|
static RELOC_PTRS_WITH(pdf14_device_reloc_ptrs, pdf14_device *pdev)
{
{
int i;
for (i = 0; i < pdev->devn_params.separations.num_separations; ++i) {
RELOC_PTR(pdf14_device, devn_params.separations.names[i].data);
}
}
RELOC_VAR(pdev->ctx);
RELOC_VAR(pdev->smaskcolor);
RELOC_VAR(pdev->trans_group_parent_cmap_procs);
pdev->target = gx_device_reloc_ptr(pdev->target, gcst);
pdev->pclist_device = gx_device_reloc_ptr(pdev->pclist_device, gcst);
}
| null | 0
|
static RELOC_PTRS_WITH(pdf14_device_reloc_ptrs, pdf14_device *pdev)
{
{
int i;
for (i = 0; i < pdev->devn_params.separations.num_separations; ++i) {
RELOC_PTR(pdf14_device, devn_params.separations.names[i].data);
}
}
RELOC_VAR(pdev->ctx);
RELOC_VAR(pdev->smaskcolor);
RELOC_VAR(pdev->trans_group_parent_cmap_procs);
pdev->target = gx_device_reloc_ptr(pdev->target, gcst);
pdev->pclist_device = gx_device_reloc_ptr(pdev->pclist_device, gcst);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,336
|
static pdf14_device *find_pdf14_device(gx_device *dev)
{
pdf14_device *pdev;
if (dev_proc(dev, dev_spec_op)(dev, gxdso_is_pdf14_device, &pdev, sizeof(pdev)) <= 0)
return NULL;
return pdev;
}
| null | 0
|
static pdf14_device *find_pdf14_device(gx_device *dev)
{
pdf14_device *pdev;
if (dev_proc(dev, dev_spec_op)(dev, gxdso_is_pdf14_device, &pdev, sizeof(pdev)) <= 0)
return NULL;
return pdev;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,337
|
gs_pdf14_device_copy_params(gx_device *dev, const gx_device *target)
{
cmm_dev_profile_t *profile_targ;
cmm_dev_profile_t *profile_dev14;
pdf14_device *pdev = (pdf14_device*) dev;
COPY_PARAM(width);
COPY_PARAM(height);
COPY_ARRAY_PARAM(MediaSize);
COPY_ARRAY_PARAM(ImagingBBox);
COPY_PARAM(ImagingBBox_set);
COPY_ARRAY_PARAM(HWResolution);
COPY_ARRAY_PARAM(Margins);
COPY_ARRAY_PARAM(HWMargins);
COPY_PARAM(PageCount);
COPY_PARAM(MaxPatternBitmap);
COPY_PARAM(graphics_type_tag);
COPY_PARAM(interpolate_control);
memcpy(&(dev->space_params), &(target->space_params), sizeof(gdev_space_params));
/* The PDF14 device copies only the default profile not the text etc.
TODO: MJV. It has to make its own device structure but
can grab a copy of the profile. This allows swapping of profiles
in the PDF14 device without messing up the target device profile.
Also if the device is using a blend color space it will grab that too */
if (dev->icc_struct == NULL) {
dev->icc_struct = gsicc_new_device_profile_array(dev->memory);
profile_dev14 = dev->icc_struct;
dev_proc((gx_device *) target, get_profile)((gx_device *) target,
&(profile_targ));
gsicc_adjust_profile_rc(profile_targ->device_profile[0], 1, "gs_pdf14_device_copy_params");
if (profile_dev14->device_profile[0] != NULL) {
gsicc_adjust_profile_rc(profile_dev14->device_profile[0], -1, "gs_pdf14_device_copy_params");
}
profile_dev14->device_profile[0] = profile_targ->device_profile[0];
dev->icc_struct->devicegraytok = profile_targ->devicegraytok;
dev->icc_struct->graydetection = profile_targ->graydetection;
dev->icc_struct->pageneutralcolor = profile_targ->pageneutralcolor;
dev->icc_struct->supports_devn = profile_targ->supports_devn;
dev->icc_struct->usefastcolor = profile_targ->usefastcolor;
profile_dev14->rendercond[0] = profile_targ->rendercond[0];
if (pdev->using_blend_cs) {
/* Swap the device profile and the blend profile. */
gsicc_adjust_profile_rc(profile_targ->device_profile[0], 1, "gs_pdf14_device_copy_params");
gsicc_adjust_profile_rc(profile_targ->blend_profile, 1, "gs_pdf14_device_copy_params");
gsicc_adjust_profile_rc(profile_dev14->device_profile[0], -1, "gs_pdf14_device_copy_params");
gsicc_adjust_profile_rc(profile_dev14->blend_profile, -1, "gs_pdf14_device_copy_params");
profile_dev14->blend_profile = profile_targ->device_profile[0];
profile_dev14->device_profile[0] = profile_targ->blend_profile;
}
profile_dev14->sim_overprint = profile_targ->sim_overprint;
}
#undef COPY_ARRAY_PARAM
#undef COPY_PARAM
}
| null | 0
|
gs_pdf14_device_copy_params(gx_device *dev, const gx_device *target)
{
cmm_dev_profile_t *profile_targ;
cmm_dev_profile_t *profile_dev14;
pdf14_device *pdev = (pdf14_device*) dev;
COPY_PARAM(width);
COPY_PARAM(height);
COPY_ARRAY_PARAM(MediaSize);
COPY_ARRAY_PARAM(ImagingBBox);
COPY_PARAM(ImagingBBox_set);
COPY_ARRAY_PARAM(HWResolution);
COPY_ARRAY_PARAM(Margins);
COPY_ARRAY_PARAM(HWMargins);
COPY_PARAM(PageCount);
COPY_PARAM(MaxPatternBitmap);
COPY_PARAM(graphics_type_tag);
COPY_PARAM(interpolate_control);
memcpy(&(dev->space_params), &(target->space_params), sizeof(gdev_space_params));
/* The PDF14 device copies only the default profile not the text etc.
TODO: MJV. It has to make its own device structure but
can grab a copy of the profile. This allows swapping of profiles
in the PDF14 device without messing up the target device profile.
Also if the device is using a blend color space it will grab that too */
if (dev->icc_struct == NULL) {
dev->icc_struct = gsicc_new_device_profile_array(dev->memory);
profile_dev14 = dev->icc_struct;
dev_proc((gx_device *) target, get_profile)((gx_device *) target,
&(profile_targ));
gsicc_adjust_profile_rc(profile_targ->device_profile[0], 1, "gs_pdf14_device_copy_params");
if (profile_dev14->device_profile[0] != NULL) {
gsicc_adjust_profile_rc(profile_dev14->device_profile[0], -1, "gs_pdf14_device_copy_params");
}
profile_dev14->device_profile[0] = profile_targ->device_profile[0];
dev->icc_struct->devicegraytok = profile_targ->devicegraytok;
dev->icc_struct->graydetection = profile_targ->graydetection;
dev->icc_struct->pageneutralcolor = profile_targ->pageneutralcolor;
dev->icc_struct->supports_devn = profile_targ->supports_devn;
dev->icc_struct->usefastcolor = profile_targ->usefastcolor;
profile_dev14->rendercond[0] = profile_targ->rendercond[0];
if (pdev->using_blend_cs) {
/* Swap the device profile and the blend profile. */
gsicc_adjust_profile_rc(profile_targ->device_profile[0], 1, "gs_pdf14_device_copy_params");
gsicc_adjust_profile_rc(profile_targ->blend_profile, 1, "gs_pdf14_device_copy_params");
gsicc_adjust_profile_rc(profile_dev14->device_profile[0], -1, "gs_pdf14_device_copy_params");
gsicc_adjust_profile_rc(profile_dev14->blend_profile, -1, "gs_pdf14_device_copy_params");
profile_dev14->blend_profile = profile_targ->device_profile[0];
profile_dev14->device_profile[0] = profile_targ->blend_profile;
}
profile_dev14->sim_overprint = profile_targ->sim_overprint;
}
#undef COPY_ARRAY_PARAM
#undef COPY_PARAM
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,338
|
gx_update_pdf14_compositor(gx_device * pdev, gs_gstate * pgs,
const gs_pdf14trans_t * pdf14pct, gs_memory_t * mem )
{
pdf14_device *p14dev = (pdf14_device *)pdev;
gs_pdf14trans_params_t params = pdf14pct->params;
int code = 0;
params.idle = pdf14pct->idle;
switch (params.pdf14_op) {
default: /* Should not occur. */
break;
case PDF14_PUSH_DEVICE:
if (!(params.is_pattern)) {
p14dev->blend_mode = 0;
p14dev->opacity = p14dev->shape = 0.0;
pdf14_recreate_device(mem, pgs, pdev, pdf14pct);
}
break;
case PDF14_ABORT_DEVICE:
/* Something has gone very wrong. Let transparency device clean up
what ever it has allocated and then we are shutting it down */
code = gx_abort_trans_device(pgs, pdev);
if (p14dev->free_devicen) {
devn_free_params(pdev);
}
pdf14_disable_device(pdev);
pdf14_close(pdev);
break;
case PDF14_POP_DEVICE:
if (!(params.is_pattern)) {
if_debug0m('v', pdev->memory,
"[v]gx_update_pdf14_compositor(PDF14_POP_DEVICE)\n");
pgs->get_cmap_procs = p14dev->save_get_cmap_procs;
gx_set_cmap_procs(pgs, p14dev->target);
/* Send image out raster data to output device */
{
/* Make a copy so we can change the ROP */
gs_gstate new_pgs = *pgs;
/* We don't use the gs_gstate log_op since this is for the */
/* clist playback. Putting the image (band in the case of the */
/* clist) only needs to use the default ROP to copy the data */
new_pgs.log_op = rop3_default;
code = p14dev->pdf14_procs->put_image(pdev, &new_pgs, p14dev->target);
}
/* Before we disable the device release any deviceN structures.
free_devicen is set if the pdf14 device had inherited its
deviceN parameters from the target clist device. In this
case they should not be freed */
if (p14dev->free_devicen) {
devn_free_params(pdev);
}
pdf14_disable_device(pdev);
pdf14_close(pdev);
}
break;
case PDF14_BEGIN_TRANS_GROUP:
code = gx_begin_transparency_group(pgs, pdev, ¶ms);
break;
case PDF14_END_TRANS_GROUP:
code = gx_end_transparency_group(pgs, pdev);
break;
case PDF14_BEGIN_TRANS_TEXT_GROUP:
p14dev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
break;
case PDF14_END_TRANS_TEXT_GROUP:
if (p14dev->text_group == PDF14_TEXTGROUP_BT_PUSHED)
code = gx_end_transparency_group(pgs, pdev);
p14dev->text_group = PDF14_TEXTGROUP_NO_BT; /* Hit ET */
break;
case PDF14_BEGIN_TRANS_MASK:
code = gx_begin_transparency_mask(pgs, pdev, ¶ms);
break;
case PDF14_END_TRANS_MASK:
code = gx_end_transparency_mask(pgs, pdev, ¶ms);
break;
case PDF14_SET_BLEND_PARAMS:
pdf14_set_params(pgs, pdev, &pdf14pct->params);
break;
case PDF14_PUSH_TRANS_STATE:
code = gx_push_transparency_state(pgs, pdev);
break;
case PDF14_POP_TRANS_STATE:
code = gx_pop_transparency_state(pgs, pdev);
break;
case PDF14_PUSH_SMASK_COLOR:
code = pdf14_increment_smask_color(pgs, pdev);
break;
case PDF14_POP_SMASK_COLOR:
code = pdf14_decrement_smask_color(pgs, pdev);
break;
}
return code;
}
| null | 0
|
gx_update_pdf14_compositor(gx_device * pdev, gs_gstate * pgs,
const gs_pdf14trans_t * pdf14pct, gs_memory_t * mem )
{
pdf14_device *p14dev = (pdf14_device *)pdev;
gs_pdf14trans_params_t params = pdf14pct->params;
int code = 0;
params.idle = pdf14pct->idle;
switch (params.pdf14_op) {
default: /* Should not occur. */
break;
case PDF14_PUSH_DEVICE:
if (!(params.is_pattern)) {
p14dev->blend_mode = 0;
p14dev->opacity = p14dev->shape = 0.0;
pdf14_recreate_device(mem, pgs, pdev, pdf14pct);
}
break;
case PDF14_ABORT_DEVICE:
/* Something has gone very wrong. Let transparency device clean up
what ever it has allocated and then we are shutting it down */
code = gx_abort_trans_device(pgs, pdev);
if (p14dev->free_devicen) {
devn_free_params(pdev);
}
pdf14_disable_device(pdev);
pdf14_close(pdev);
break;
case PDF14_POP_DEVICE:
if (!(params.is_pattern)) {
if_debug0m('v', pdev->memory,
"[v]gx_update_pdf14_compositor(PDF14_POP_DEVICE)\n");
pgs->get_cmap_procs = p14dev->save_get_cmap_procs;
gx_set_cmap_procs(pgs, p14dev->target);
/* Send image out raster data to output device */
{
/* Make a copy so we can change the ROP */
gs_gstate new_pgs = *pgs;
/* We don't use the gs_gstate log_op since this is for the */
/* clist playback. Putting the image (band in the case of the */
/* clist) only needs to use the default ROP to copy the data */
new_pgs.log_op = rop3_default;
code = p14dev->pdf14_procs->put_image(pdev, &new_pgs, p14dev->target);
}
/* Before we disable the device release any deviceN structures.
free_devicen is set if the pdf14 device had inherited its
deviceN parameters from the target clist device. In this
case they should not be freed */
if (p14dev->free_devicen) {
devn_free_params(pdev);
}
pdf14_disable_device(pdev);
pdf14_close(pdev);
}
break;
case PDF14_BEGIN_TRANS_GROUP:
code = gx_begin_transparency_group(pgs, pdev, ¶ms);
break;
case PDF14_END_TRANS_GROUP:
code = gx_end_transparency_group(pgs, pdev);
break;
case PDF14_BEGIN_TRANS_TEXT_GROUP:
p14dev->text_group = PDF14_TEXTGROUP_BT_NOT_PUSHED;
break;
case PDF14_END_TRANS_TEXT_GROUP:
if (p14dev->text_group == PDF14_TEXTGROUP_BT_PUSHED)
code = gx_end_transparency_group(pgs, pdev);
p14dev->text_group = PDF14_TEXTGROUP_NO_BT; /* Hit ET */
break;
case PDF14_BEGIN_TRANS_MASK:
code = gx_begin_transparency_mask(pgs, pdev, ¶ms);
break;
case PDF14_END_TRANS_MASK:
code = gx_end_transparency_mask(pgs, pdev, ¶ms);
break;
case PDF14_SET_BLEND_PARAMS:
pdf14_set_params(pgs, pdev, &pdf14pct->params);
break;
case PDF14_PUSH_TRANS_STATE:
code = gx_push_transparency_state(pgs, pdev);
break;
case PDF14_POP_TRANS_STATE:
code = gx_pop_transparency_state(pgs, pdev);
break;
case PDF14_PUSH_SMASK_COLOR:
code = pdf14_increment_smask_color(pgs, pdev);
break;
case PDF14_POP_SMASK_COLOR:
code = pdf14_decrement_smask_color(pgs, pdev);
break;
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,339
|
no_print_page(gx_device_printer *pdev, FILE *prn_stream)
{
return_error(gs_error_unknownerror);
}
| null | 0
|
no_print_page(gx_device_printer *pdev, FILE *prn_stream)
{
return_error(gs_error_unknownerror);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,340
|
pdf14_begin_typed_image(gx_device * dev, const gs_gstate * pgs,
const gs_matrix *pmat, const gs_image_common_t *pic,
const gs_int_rect * prect,
const gx_drawing_color * pdcolor,
const gx_clip_path * pcpath, gs_memory_t * mem,
gx_image_enum_common_t ** pinfo)
{
const gs_image_t *pim = (const gs_image_t *)pic;
int code;
/* If we are filling an image mask with a pattern that has a transparency
then we need to do some special handling */
if (pim->ImageMask) {
if (pdcolor != NULL && gx_dc_is_pattern1_color(pdcolor)) {
if( gx_pattern1_get_transptr(pdcolor) != NULL){
/* If we are in a final run through here for this case then
go ahead and push the transparency group. Also, update
the proc for the pattern color so that we used the
appropriate fill operation. Note that the group
is popped and the proc will be reset when we flush the
image data. This is handled in a special pdf14 image
renderer which will end up installed for this case.
Detect setting of begin_image to gx_no_begin_image.
(final recursive call) */
if (dev_proc(dev, begin_image) != gx_default_begin_image) {
code = pdf14_patt_trans_image_fill(dev, pgs, pmat, pic,
prect, pdcolor, pcpath, mem,
pinfo);
return code;
}
}
}
}
pdf14_set_marking_params(dev, pgs);
return gx_default_begin_typed_image(dev, pgs, pmat, pic, prect, pdcolor,
pcpath, mem, pinfo);
}
| null | 0
|
pdf14_begin_typed_image(gx_device * dev, const gs_gstate * pgs,
const gs_matrix *pmat, const gs_image_common_t *pic,
const gs_int_rect * prect,
const gx_drawing_color * pdcolor,
const gx_clip_path * pcpath, gs_memory_t * mem,
gx_image_enum_common_t ** pinfo)
{
const gs_image_t *pim = (const gs_image_t *)pic;
int code;
/* If we are filling an image mask with a pattern that has a transparency
then we need to do some special handling */
if (pim->ImageMask) {
if (pdcolor != NULL && gx_dc_is_pattern1_color(pdcolor)) {
if( gx_pattern1_get_transptr(pdcolor) != NULL){
/* If we are in a final run through here for this case then
go ahead and push the transparency group. Also, update
the proc for the pattern color so that we used the
appropriate fill operation. Note that the group
is popped and the proc will be reset when we flush the
image data. This is handled in a special pdf14 image
renderer which will end up installed for this case.
Detect setting of begin_image to gx_no_begin_image.
(final recursive call) */
if (dev_proc(dev, begin_image) != gx_default_begin_image) {
code = pdf14_patt_trans_image_fill(dev, pgs, pmat, pic,
prect, pdcolor, pcpath, mem,
pinfo);
return code;
}
}
}
}
pdf14_set_marking_params(dev, pgs);
return gx_default_begin_typed_image(dev, pgs, pmat, pic, prect, pdcolor,
pcpath, mem, pinfo);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,341
|
pdf14_buf_free(pdf14_buf *buf)
{
pdf14_parent_color_t *old_parent_color_info = buf->parent_color_info_procs;
gs_memory_t *memory = buf->memory;
if (buf->mask_stack && buf->mask_stack->rc_mask)
rc_decrement(buf->mask_stack->rc_mask, "pdf14_buf_free");
gs_free_object(memory, buf->mask_stack, "pdf14_buf_free");
gs_free_object(memory, buf->transfer_fn, "pdf14_buf_free");
gs_free_object(memory, buf->matte, "pdf14_buf_free");
gs_free_object(memory, buf->data, "pdf14_buf_free");
while (old_parent_color_info) {
if (old_parent_color_info->icc_profile != NULL) {
gsicc_adjust_profile_rc(old_parent_color_info->icc_profile, -1, "pdf14_buf_free");
}
buf->parent_color_info_procs = old_parent_color_info->previous;
gs_free_object(memory, old_parent_color_info, "pdf14_buf_free");
old_parent_color_info = buf->parent_color_info_procs;
}
gs_free_object(memory, buf->backdrop, "pdf14_buf_free");
gs_free_object(memory, buf, "pdf14_buf_free");
}
| null | 0
|
pdf14_buf_free(pdf14_buf *buf)
{
pdf14_parent_color_t *old_parent_color_info = buf->parent_color_info_procs;
gs_memory_t *memory = buf->memory;
if (buf->mask_stack && buf->mask_stack->rc_mask)
rc_decrement(buf->mask_stack->rc_mask, "pdf14_buf_free");
gs_free_object(memory, buf->mask_stack, "pdf14_buf_free");
gs_free_object(memory, buf->transfer_fn, "pdf14_buf_free");
gs_free_object(memory, buf->matte, "pdf14_buf_free");
gs_free_object(memory, buf->data, "pdf14_buf_free");
while (old_parent_color_info) {
if (old_parent_color_info->icc_profile != NULL) {
gsicc_adjust_profile_rc(old_parent_color_info->icc_profile, -1, "pdf14_buf_free");
}
buf->parent_color_info_procs = old_parent_color_info->previous;
gs_free_object(memory, old_parent_color_info, "pdf14_buf_free");
old_parent_color_info = buf->parent_color_info_procs;
}
gs_free_object(memory, buf->backdrop, "pdf14_buf_free");
gs_free_object(memory, buf, "pdf14_buf_free");
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,342
|
pdf14_buf_new(gs_int_rect *rect, bool has_tags, bool has_alpha_g,
bool has_shape, bool idle, int n_chan, int num_spots,
gs_memory_t *memory)
{
/* Note that alpha_g is the alpha for the GROUP */
/* This is distinct from the alpha that may also exist */
/* for the objects within the group. Hence it can introduce */
/* yet another plane */
pdf14_buf *result;
pdf14_parent_color_t *new_parent_color;
int rowstride = (rect->q.x - rect->p.x + 3) & -4;
int height = (rect->q.y - rect->p.y);
int n_planes = n_chan + (has_shape ? 1 : 0) + (has_alpha_g ? 1 : 0) +
(has_tags ? 1 : 0);
int planestride;
double dsize = (((double) rowstride) * height) * n_planes;
if (dsize > (double)max_uint)
return NULL;
result = gs_alloc_struct(memory, pdf14_buf, &st_pdf14_buf,
"pdf14_buf_new");
if (result == NULL)
return result;
result->memory = memory;
result->backdrop = NULL;
result->saved = NULL;
result->isolated = false;
result->knockout = false;
result->has_alpha_g = has_alpha_g;
result->has_shape = has_shape;
result->has_tags = has_tags;
result->rect = *rect;
result->n_chan = n_chan;
result->n_planes = n_planes;
result->rowstride = rowstride;
result->transfer_fn = NULL;
result->matte_num_comps = 0;
result->matte = NULL;
result->mask_stack = NULL;
result->idle = idle;
result->mask_id = 0;
result->num_spots = num_spots;
new_parent_color = gs_alloc_struct(memory, pdf14_parent_color_t, &st_pdf14_clr,
"pdf14_buf_new");
if (new_parent_color == NULL) {
gs_free_object(memory, result, "pdf14_buf_new");
return NULL;
}
result->parent_color_info_procs = new_parent_color;
result->parent_color_info_procs->get_cmap_procs = NULL;
result->parent_color_info_procs->parent_color_mapping_procs = NULL;
result->parent_color_info_procs->parent_color_comp_index = NULL;
result->parent_color_info_procs->icc_profile = NULL;
result->parent_color_info_procs->previous = NULL;
result->parent_color_info_procs->encode = NULL;
result->parent_color_info_procs->decode = NULL;
if (idle || height <= 0) {
/* Empty clipping - will skip all drawings. */
result->planestride = 0;
result->data = 0;
} else {
planestride = rowstride * height;
result->planestride = planestride;
result->data = gs_alloc_bytes(memory, planestride * n_planes,
"pdf14_buf_new");
if (result->data == NULL) {
gs_free_object(memory, result, "pdf14_buf_new");
return NULL;
}
if (has_alpha_g) {
int alpha_g_plane = n_chan + (has_shape ? 1 : 0);
memset (result->data + alpha_g_plane * planestride, 0, planestride);
}
if (has_tags) {
int tags_plane = n_chan + (has_shape ? 1 : 0) + (has_alpha_g ? 1 : 0);
memset (result->data + tags_plane * planestride,
GS_UNTOUCHED_TAG, planestride);
}
}
/* Initialize dirty box with an invalid rectangle (the reversed rectangle).
* Any future drawing will make it valid again, so we won't blend back
* more than we need. */
result->dirty.p.x = rect->q.x;
result->dirty.p.y = rect->q.y;
result->dirty.q.x = rect->p.x;
result->dirty.q.y = rect->p.y;
return result;
}
| null | 0
|
pdf14_buf_new(gs_int_rect *rect, bool has_tags, bool has_alpha_g,
bool has_shape, bool idle, int n_chan, int num_spots,
gs_memory_t *memory)
{
/* Note that alpha_g is the alpha for the GROUP */
/* This is distinct from the alpha that may also exist */
/* for the objects within the group. Hence it can introduce */
/* yet another plane */
pdf14_buf *result;
pdf14_parent_color_t *new_parent_color;
int rowstride = (rect->q.x - rect->p.x + 3) & -4;
int height = (rect->q.y - rect->p.y);
int n_planes = n_chan + (has_shape ? 1 : 0) + (has_alpha_g ? 1 : 0) +
(has_tags ? 1 : 0);
int planestride;
double dsize = (((double) rowstride) * height) * n_planes;
if (dsize > (double)max_uint)
return NULL;
result = gs_alloc_struct(memory, pdf14_buf, &st_pdf14_buf,
"pdf14_buf_new");
if (result == NULL)
return result;
result->memory = memory;
result->backdrop = NULL;
result->saved = NULL;
result->isolated = false;
result->knockout = false;
result->has_alpha_g = has_alpha_g;
result->has_shape = has_shape;
result->has_tags = has_tags;
result->rect = *rect;
result->n_chan = n_chan;
result->n_planes = n_planes;
result->rowstride = rowstride;
result->transfer_fn = NULL;
result->matte_num_comps = 0;
result->matte = NULL;
result->mask_stack = NULL;
result->idle = idle;
result->mask_id = 0;
result->num_spots = num_spots;
new_parent_color = gs_alloc_struct(memory, pdf14_parent_color_t, &st_pdf14_clr,
"pdf14_buf_new");
if (new_parent_color == NULL) {
gs_free_object(memory, result, "pdf14_buf_new");
return NULL;
}
result->parent_color_info_procs = new_parent_color;
result->parent_color_info_procs->get_cmap_procs = NULL;
result->parent_color_info_procs->parent_color_mapping_procs = NULL;
result->parent_color_info_procs->parent_color_comp_index = NULL;
result->parent_color_info_procs->icc_profile = NULL;
result->parent_color_info_procs->previous = NULL;
result->parent_color_info_procs->encode = NULL;
result->parent_color_info_procs->decode = NULL;
if (idle || height <= 0) {
/* Empty clipping - will skip all drawings. */
result->planestride = 0;
result->data = 0;
} else {
planestride = rowstride * height;
result->planestride = planestride;
result->data = gs_alloc_bytes(memory, planestride * n_planes,
"pdf14_buf_new");
if (result->data == NULL) {
gs_free_object(memory, result, "pdf14_buf_new");
return NULL;
}
if (has_alpha_g) {
int alpha_g_plane = n_chan + (has_shape ? 1 : 0);
memset (result->data + alpha_g_plane * planestride, 0, planestride);
}
if (has_tags) {
int tags_plane = n_chan + (has_shape ? 1 : 0) + (has_alpha_g ? 1 : 0);
memset (result->data + tags_plane * planestride,
GS_UNTOUCHED_TAG, planestride);
}
}
/* Initialize dirty box with an invalid rectangle (the reversed rectangle).
* Any future drawing will make it valid again, so we won't blend back
* more than we need. */
result->dirty.p.x = rect->q.x;
result->dirty.p.y = rect->q.y;
result->dirty.q.x = rect->p.x;
result->dirty.q.y = rect->p.y;
return result;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,343
|
static void pdf14_cleanup_parent_color_profiles (pdf14_device *pdev)
{
if (pdev->ctx) {
pdf14_buf *buf, *next;
for (buf = pdev->ctx->stack; buf != NULL; buf = next) {
pdf14_parent_color_t *old_parent_color_info = buf->parent_color_info_procs;
next = buf->saved;
while (old_parent_color_info) {
if (old_parent_color_info->icc_profile != NULL) {
cmm_profile_t *group_profile;
gsicc_rendering_param_t render_cond;
cmm_dev_profile_t *dev_profile;
int code = dev_proc((gx_device *)pdev, get_profile)((gx_device *)pdev, &dev_profile);
if (code >= 0) {
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &group_profile,
&render_cond);
gsicc_adjust_profile_rc(pdev->icc_struct->device_profile[0], -1, "pdf14_end_transparency_group");
pdev->icc_struct->device_profile[0] = old_parent_color_info->icc_profile;
old_parent_color_info->icc_profile = NULL;
}
}
old_parent_color_info = old_parent_color_info->previous;
}
}
}
}
| null | 0
|
static void pdf14_cleanup_parent_color_profiles (pdf14_device *pdev)
{
if (pdev->ctx) {
pdf14_buf *buf, *next;
for (buf = pdev->ctx->stack; buf != NULL; buf = next) {
pdf14_parent_color_t *old_parent_color_info = buf->parent_color_info_procs;
next = buf->saved;
while (old_parent_color_info) {
if (old_parent_color_info->icc_profile != NULL) {
cmm_profile_t *group_profile;
gsicc_rendering_param_t render_cond;
cmm_dev_profile_t *dev_profile;
int code = dev_proc((gx_device *)pdev, get_profile)((gx_device *)pdev, &dev_profile);
if (code >= 0) {
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &group_profile,
&render_cond);
gsicc_adjust_profile_rc(pdev->icc_struct->device_profile[0], -1, "pdf14_end_transparency_group");
pdev->icc_struct->device_profile[0] = old_parent_color_info->icc_profile;
old_parent_color_info->icc_profile = NULL;
}
}
old_parent_color_info = old_parent_color_info->previous;
}
}
}
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,344
|
pdf14_close(gx_device *dev)
{
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_cleanup_parent_color_profiles (pdev);
if (pdev->ctx) {
pdf14_ctx_free(pdev->ctx);
pdev->ctx = NULL;
}
return 0;
}
| null | 0
|
pdf14_close(gx_device *dev)
{
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_cleanup_parent_color_profiles (pdev);
if (pdev->ctx) {
pdf14_ctx_free(pdev->ctx);
pdev->ctx = NULL;
}
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,345
|
pdf14_cmykspot_get_color_mapping_procs(const gx_device * dev)
{
return &pdf14_DeviceCMYKspot_procs;
}
| null | 0
|
pdf14_cmykspot_get_color_mapping_procs(const gx_device * dev)
{
return &pdf14_DeviceCMYKspot_procs;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,346
|
pdf14_cmykspot_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
{
pdf14_device * pdev = (pdf14_device *)dev;
pdf14_buf *buf = pdev->ctx->stack;
gs_int_rect rect = buf->rect;
int x1, y1, width, height;
gs_devn_params * pdevn_params = &pdev->devn_params;
gs_separations * pseparations = &pdevn_params->separations;
int planestride = buf->planestride;
int rowstride = buf->rowstride;
const byte bg = pdev->ctx->additive ? 0xff : 0;
int num_comp = buf->n_chan - 1;
byte *buf_ptr;
if_debug0m('v', dev->memory, "[v]pdf14_cmykspot_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
width = x1 - rect.p.x;
height = y1 - rect.p.y;
if (width <= 0 || height <= 0 || buf->data == NULL)
return 0;
buf_ptr = buf->data + rect.p.y * buf->rowstride + rect.p.x;
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(pdev->ctx->stack->rect.q.y-pdev->ctx->stack->rect.p.y,
pdev->ctx->stack->rect.q.x-pdev->ctx->stack->rect.p.x,
pdev->ctx->stack->n_planes,
pdev->ctx->stack->planestride, pdev->ctx->stack->rowstride,
"CMYK_SPOT_PUTIMAGE",pdev->ctx->stack->data);
global_index++;
clist_band_count++;
#endif
return gx_put_blended_image_cmykspot(target, buf_ptr, planestride, rowstride,
rect.p.x, rect.p.y, width, height, num_comp, bg,
buf->has_tags, rect, pseparations);
}
| null | 0
|
pdf14_cmykspot_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
{
pdf14_device * pdev = (pdf14_device *)dev;
pdf14_buf *buf = pdev->ctx->stack;
gs_int_rect rect = buf->rect;
int x1, y1, width, height;
gs_devn_params * pdevn_params = &pdev->devn_params;
gs_separations * pseparations = &pdevn_params->separations;
int planestride = buf->planestride;
int rowstride = buf->rowstride;
const byte bg = pdev->ctx->additive ? 0xff : 0;
int num_comp = buf->n_chan - 1;
byte *buf_ptr;
if_debug0m('v', dev->memory, "[v]pdf14_cmykspot_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
width = x1 - rect.p.x;
height = y1 - rect.p.y;
if (width <= 0 || height <= 0 || buf->data == NULL)
return 0;
buf_ptr = buf->data + rect.p.y * buf->rowstride + rect.p.x;
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(pdev->ctx->stack->rect.q.y-pdev->ctx->stack->rect.p.y,
pdev->ctx->stack->rect.q.x-pdev->ctx->stack->rect.p.x,
pdev->ctx->stack->n_planes,
pdev->ctx->stack->planestride, pdev->ctx->stack->rowstride,
"CMYK_SPOT_PUTIMAGE",pdev->ctx->stack->data);
global_index++;
clist_band_count++;
#endif
return gx_put_blended_image_cmykspot(target, buf_ptr, planestride, rowstride,
rect.p.x, rect.p.y, width, height, num_comp, bg,
buf->has_tags, rect, pseparations);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,347
|
pdf14_copy_alpha(gx_device * dev, const byte * data, int data_x,
int aa_raster, gx_bitmap_id id, int x, int y, int w, int h,
gx_color_index color, int depth)
{
return pdf14_copy_alpha_color(dev, data, data_x, aa_raster, id, x, y, w, h,
color, NULL, depth, false);
}
| null | 0
|
pdf14_copy_alpha(gx_device * dev, const byte * data, int data_x,
int aa_raster, gx_bitmap_id id, int x, int y, int w, int h,
gx_color_index color, int depth)
{
return pdf14_copy_alpha_color(dev, data, data_x, aa_raster, id, x, y, w, h,
color, NULL, depth, false);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,348
|
pdf14_copy_alpha_hl_color(gx_device * dev, const byte * data, int data_x,
int aa_raster, gx_bitmap_id id, int x, int y, int w, int h,
const gx_drawing_color *pdcolor, int depth)
{
return pdf14_copy_alpha_color(dev, data, data_x, aa_raster, id, x, y, w, h,
0, pdcolor, depth, true);
}
| null | 0
|
pdf14_copy_alpha_hl_color(gx_device * dev, const byte * data, int data_x,
int aa_raster, gx_bitmap_id id, int x, int y, int w, int h,
const gx_drawing_color *pdcolor, int depth)
{
return pdf14_copy_alpha_color(dev, data, data_x, aa_raster, id, x, y, w, h,
0, pdcolor, depth, true);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,349
|
pdf14_create_compositor(gx_device * dev, gx_device * * pcdev,
const gs_composite_t * pct, gs_gstate * pgs,
gs_memory_t * mem, gx_device *cdev)
{
pdf14_device *p14dev = (pdf14_device *)dev;
if (gs_is_pdf14trans_compositor(pct)) {
const gs_pdf14trans_t * pdf14pct = (const gs_pdf14trans_t *) pct;
*pcdev = dev;
/* cdev, may be the clist reader device which may contain information that
we will need related to the ICC color spaces that define transparency
groups. We want this propogated through all the pdf14 functions. Store
a pointer to it in the pdf14 device */
p14dev->pclist_device = cdev;
return gx_update_pdf14_compositor(dev, pgs, pdf14pct, mem);
} else if (gs_is_overprint_compositor(pct)) {
/* If we had an overprint compositer action, then the
color components that were drawn should be updated.
The overprint compositor logic and its interactions
with the clist is a little odd as it passes uninitialized
values around a fair amount. Hence the forced assignement here.
See gx_spot_colors_set_overprint in gscspace for issues... */
const gs_overprint_t * op_pct = (const gs_overprint_t *) pct;
if (op_pct->params.retain_any_comps && !op_pct->params.retain_spot_comps) {
p14dev->drawn_comps = op_pct->params.drawn_comps;
} else {
/* Draw everything. If this parameter was not set, clist does
not fill it in. */
p14dev->drawn_comps = ( (gx_color_index) 1 << (p14dev->color_info.num_components)) - (gx_color_index) 1;
}
*pcdev = dev;
return 0;
} else
return gx_no_create_compositor(dev, pcdev, pct, pgs, mem, cdev);
}
| null | 0
|
pdf14_create_compositor(gx_device * dev, gx_device * * pcdev,
const gs_composite_t * pct, gs_gstate * pgs,
gs_memory_t * mem, gx_device *cdev)
{
pdf14_device *p14dev = (pdf14_device *)dev;
if (gs_is_pdf14trans_compositor(pct)) {
const gs_pdf14trans_t * pdf14pct = (const gs_pdf14trans_t *) pct;
*pcdev = dev;
/* cdev, may be the clist reader device which may contain information that
we will need related to the ICC color spaces that define transparency
groups. We want this propogated through all the pdf14 functions. Store
a pointer to it in the pdf14 device */
p14dev->pclist_device = cdev;
return gx_update_pdf14_compositor(dev, pgs, pdf14pct, mem);
} else if (gs_is_overprint_compositor(pct)) {
/* If we had an overprint compositer action, then the
color components that were drawn should be updated.
The overprint compositor logic and its interactions
with the clist is a little odd as it passes uninitialized
values around a fair amount. Hence the forced assignement here.
See gx_spot_colors_set_overprint in gscspace for issues... */
const gs_overprint_t * op_pct = (const gs_overprint_t *) pct;
if (op_pct->params.retain_any_comps && !op_pct->params.retain_spot_comps) {
p14dev->drawn_comps = op_pct->params.drawn_comps;
} else {
/* Draw everything. If this parameter was not set, clist does
not fill it in. */
p14dev->drawn_comps = ( (gx_color_index) 1 << (p14dev->color_info.num_components)) - (gx_color_index) 1;
}
*pcdev = dev;
return 0;
} else
return gx_no_create_compositor(dev, pcdev, pct, pgs, mem, cdev);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,350
|
pdf14_ctx_free(pdf14_ctx *ctx)
{
pdf14_buf *buf, *next;
if (ctx->mask_stack) {
/* A mask was created but was not used in this band. */
rc_decrement(ctx->mask_stack->rc_mask, "pdf14_ctx_free");
gs_free_object(ctx->memory,ctx->mask_stack,"pdf14_ctx_free");
}
for (buf = ctx->stack; buf != NULL; buf = next) {
next = buf->saved;
pdf14_buf_free(buf);
}
gs_free_object (ctx->memory, ctx, "pdf14_ctx_free");
}
| null | 0
|
pdf14_ctx_free(pdf14_ctx *ctx)
{
pdf14_buf *buf, *next;
if (ctx->mask_stack) {
/* A mask was created but was not used in this band. */
rc_decrement(ctx->mask_stack->rc_mask, "pdf14_ctx_free");
gs_free_object(ctx->memory,ctx->mask_stack,"pdf14_ctx_free");
}
for (buf = ctx->stack; buf != NULL; buf = next) {
next = buf->saved;
pdf14_buf_free(buf);
}
gs_free_object (ctx->memory, ctx, "pdf14_ctx_free");
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,351
|
pdf14_ctx_new(gs_int_rect *rect, int n_chan, bool additive, gx_device *dev)
{
pdf14_ctx *result;
pdf14_buf *buf;
gs_memory_t *memory = dev->memory->stable_memory;
bool has_tags = device_encodes_tags(dev);
pdf14_device *pdev = (pdf14_device *)dev;
result = gs_alloc_struct(memory, pdf14_ctx, &st_pdf14_ctx, "pdf14_ctx_new");
if (result == NULL)
return result;
/* Note: buffer creation expects alpha to be in number of channels */
buf = pdf14_buf_new(rect, has_tags, false, false, false, n_chan + 1,
pdev->devn_params.page_spot_colors, memory);
if (buf == NULL) {
gs_free_object(memory, result, "pdf14_ctx_new");
return NULL;
}
if_debug4m('v', memory,
"[v]base buf: %d x %d, %d color channels, %d planes\n",
buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
if (buf->data != NULL) {
if (buf->has_tags) {
memset(buf->data, 0, buf->planestride * (buf->n_planes-1));
} else {
memset(buf->data, 0, buf->planestride * buf->n_planes);
}
}
buf->saved = NULL;
result->stack = buf;
result->mask_stack = pdf14_mask_element_new(memory);
result->mask_stack->rc_mask = pdf14_rcmask_new(memory);
result->n_chan = n_chan;
result->memory = memory;
result->rect = *rect;
result->additive = additive;
result->smask_depth = 0;
result->smask_blend = false;
return result;
}
| null | 0
|
pdf14_ctx_new(gs_int_rect *rect, int n_chan, bool additive, gx_device *dev)
{
pdf14_ctx *result;
pdf14_buf *buf;
gs_memory_t *memory = dev->memory->stable_memory;
bool has_tags = device_encodes_tags(dev);
pdf14_device *pdev = (pdf14_device *)dev;
result = gs_alloc_struct(memory, pdf14_ctx, &st_pdf14_ctx, "pdf14_ctx_new");
if (result == NULL)
return result;
/* Note: buffer creation expects alpha to be in number of channels */
buf = pdf14_buf_new(rect, has_tags, false, false, false, n_chan + 1,
pdev->devn_params.page_spot_colors, memory);
if (buf == NULL) {
gs_free_object(memory, result, "pdf14_ctx_new");
return NULL;
}
if_debug4m('v', memory,
"[v]base buf: %d x %d, %d color channels, %d planes\n",
buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
if (buf->data != NULL) {
if (buf->has_tags) {
memset(buf->data, 0, buf->planestride * (buf->n_planes-1));
} else {
memset(buf->data, 0, buf->planestride * buf->n_planes);
}
}
buf->saved = NULL;
result->stack = buf;
result->mask_stack = pdf14_mask_element_new(memory);
result->mask_stack->rc_mask = pdf14_rcmask_new(memory);
result->n_chan = n_chan;
result->memory = memory;
result->rect = *rect;
result->additive = additive;
result->smask_depth = 0;
result->smask_blend = false;
return result;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,352
|
pdf14_custom_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
{
pdf14_device * pdev = (pdf14_device *)dev;
pdf14_buf *buf = pdev->ctx->stack;
gs_int_rect rect = buf->rect;
int x0 = rect.p.x, y0 = rect.p.y;
int planestride = buf->planestride;
int rowstride = buf->rowstride;
int num_comp = buf->n_chan - 1;
const byte bg = pdev->ctx->additive ? 0xff : 0;
int x1, y1, width, height;
byte *buf_ptr;
if_debug0m('v', dev->memory, "[v]pdf14_custom_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
width = x1 - rect.p.x;
height = y1 - rect.p.y;
if (width <= 0 || height <= 0 || buf->data == NULL)
return 0;
buf_ptr = buf->data + rect.p.y * buf->rowstride + rect.p.x;
return gx_put_blended_image_custom(target, buf_ptr,
planestride, rowstride,
x0, y0, width, height, num_comp, bg);
}
| null | 0
|
pdf14_custom_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
{
pdf14_device * pdev = (pdf14_device *)dev;
pdf14_buf *buf = pdev->ctx->stack;
gs_int_rect rect = buf->rect;
int x0 = rect.p.x, y0 = rect.p.y;
int planestride = buf->planestride;
int rowstride = buf->rowstride;
int num_comp = buf->n_chan - 1;
const byte bg = pdev->ctx->additive ? 0xff : 0;
int x1, y1, width, height;
byte *buf_ptr;
if_debug0m('v', dev->memory, "[v]pdf14_custom_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
width = x1 - rect.p.x;
height = y1 - rect.p.y;
if (width <= 0 || height <= 0 || buf->data == NULL)
return 0;
buf_ptr = buf->data + rect.p.y * buf->rowstride + rect.p.x;
return gx_put_blended_image_custom(target, buf_ptr,
planestride, rowstride,
x0, y0, width, height, num_comp, bg);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,353
|
pdf14_determine_default_blend_cs(gx_device * pdev, bool use_pdf14_accum,
bool *using_blend_cs)
{
/* If a blend color space was specified, then go ahead and use that to
define the default color space for the blend modes. Only Gray, RGB
or CMYK blend color spaces are allowed. Note we do not allow this
setting if we are dealing with a separation device. */
cmm_dev_profile_t *dev_profile;
int code = dev_proc(pdev, get_profile)(pdev, &dev_profile);
bool valid_blend_cs = false;
*using_blend_cs = false;
/* Make sure any specified blend color space is valid along with other cond */
if (code == 0 && dev_profile->blend_profile != NULL && !use_pdf14_accum) {
if (!dev_profile->blend_profile->isdevlink &&
!dev_profile->blend_profile->islab &&
(dev_profile->blend_profile->data_cs == gsGRAY ||
dev_profile->blend_profile->data_cs == gsRGB ||
dev_profile->blend_profile->data_cs == gsCMYK)) {
/* Also, do not allow the use of the blend space when we are pushing
a pattern pdf14 device. Those should inherit from the parent */
if (!(gx_device_is_pattern_clist(pdev) ||
gx_device_is_pattern_accum(pdev))) {
valid_blend_cs = true;
}
}
}
/* If num components is one, just go ahead and use gray. This avoids
issues with additive/subtractive mono color devices */
if (pdev->color_info.polarity == GX_CINFO_POLARITY_ADDITIVE ||
pdev->color_info.num_components == 1) {
/*
* Note: We do not allow the SeparationOrder device parameter for
* additive devices. Thus we always have 1 colorant for DeviceGray
* and 3 colorants for DeviceRGB.
*/
if (valid_blend_cs) {
*using_blend_cs = true;
switch (dev_profile->blend_profile->num_comps) {
case 1:
return PDF14_DeviceGray;
case 3:
return PDF14_DeviceRGB;
case 4:
return PDF14_DeviceCMYK;
}
}
if (pdev->color_info.num_components == 1)
return PDF14_DeviceGray;
else
return PDF14_DeviceRGB;
} else {
/*
* Check if the device is CMYK only or CMYK plus spot colors. Note
* the CMYK plus spot colors will not support the blend color space
*/
int i, output_comp_num, num_cmyk_used = 0, num_cmyk = 0;
#if CUSTOM_BLENDING_MODE == ALWAYS_USE_CUSTOM_BLENDING
return PDF14_DeviceCustom;
#endif
/*
* Count the number of CMYK process components supported by the output
* device.
*/
for (i = 0; i < 4; i++) {
const char * pcomp_name = (const char *)DeviceCMYKComponents[i];
output_comp_num = dev_proc(pdev, get_color_comp_index)
(pdev, pcomp_name, strlen(pcomp_name), NO_COMP_NAME_TYPE);
if (output_comp_num >= 0) {
num_cmyk++;
if (output_comp_num != GX_DEVICE_COLOR_MAX_COMPONENTS)
num_cmyk_used++;
}
}
/*
* Check if the device supports only CMYK. Otherewise we assume that
* the output device supports spot colors. Note: This algorithm can
* be fooled if the SeparationOrder device parameter is being used by
* the output device device to only select CMYK.
*/
if (num_cmyk_used == 4 && pdev->color_info.num_components == 4
&& pdev->color_info.max_components == 4) {
if (valid_blend_cs) {
*using_blend_cs = true;
switch (dev_profile->blend_profile->num_comps) {
case 1:
return PDF14_DeviceGray;
case 3:
return PDF14_DeviceRGB;
case 4:
return PDF14_DeviceCMYK;
}
}
return PDF14_DeviceCMYK;
}
/*
* Check if we should use the 'custom' PDF 1.4 compositor device.
* This device is only needed for those devices which do not support
* a basic CMYK process color model.
*/
#if CUSTOM_BLENDING_MODE == AUTO_USE_CUSTOM_BLENDING
if (num_cmyk != 4)
return PDF14_DeviceCustom;
#endif
/*
* Otherewise we use a CMYK plus spot colors for blending.
*/
return PDF14_DeviceCMYKspot;
}
}
| null | 0
|
pdf14_determine_default_blend_cs(gx_device * pdev, bool use_pdf14_accum,
bool *using_blend_cs)
{
/* If a blend color space was specified, then go ahead and use that to
define the default color space for the blend modes. Only Gray, RGB
or CMYK blend color spaces are allowed. Note we do not allow this
setting if we are dealing with a separation device. */
cmm_dev_profile_t *dev_profile;
int code = dev_proc(pdev, get_profile)(pdev, &dev_profile);
bool valid_blend_cs = false;
*using_blend_cs = false;
/* Make sure any specified blend color space is valid along with other cond */
if (code == 0 && dev_profile->blend_profile != NULL && !use_pdf14_accum) {
if (!dev_profile->blend_profile->isdevlink &&
!dev_profile->blend_profile->islab &&
(dev_profile->blend_profile->data_cs == gsGRAY ||
dev_profile->blend_profile->data_cs == gsRGB ||
dev_profile->blend_profile->data_cs == gsCMYK)) {
/* Also, do not allow the use of the blend space when we are pushing
a pattern pdf14 device. Those should inherit from the parent */
if (!(gx_device_is_pattern_clist(pdev) ||
gx_device_is_pattern_accum(pdev))) {
valid_blend_cs = true;
}
}
}
/* If num components is one, just go ahead and use gray. This avoids
issues with additive/subtractive mono color devices */
if (pdev->color_info.polarity == GX_CINFO_POLARITY_ADDITIVE ||
pdev->color_info.num_components == 1) {
/*
* Note: We do not allow the SeparationOrder device parameter for
* additive devices. Thus we always have 1 colorant for DeviceGray
* and 3 colorants for DeviceRGB.
*/
if (valid_blend_cs) {
*using_blend_cs = true;
switch (dev_profile->blend_profile->num_comps) {
case 1:
return PDF14_DeviceGray;
case 3:
return PDF14_DeviceRGB;
case 4:
return PDF14_DeviceCMYK;
}
}
if (pdev->color_info.num_components == 1)
return PDF14_DeviceGray;
else
return PDF14_DeviceRGB;
} else {
/*
* Check if the device is CMYK only or CMYK plus spot colors. Note
* the CMYK plus spot colors will not support the blend color space
*/
int i, output_comp_num, num_cmyk_used = 0, num_cmyk = 0;
#if CUSTOM_BLENDING_MODE == ALWAYS_USE_CUSTOM_BLENDING
return PDF14_DeviceCustom;
#endif
/*
* Count the number of CMYK process components supported by the output
* device.
*/
for (i = 0; i < 4; i++) {
const char * pcomp_name = (const char *)DeviceCMYKComponents[i];
output_comp_num = dev_proc(pdev, get_color_comp_index)
(pdev, pcomp_name, strlen(pcomp_name), NO_COMP_NAME_TYPE);
if (output_comp_num >= 0) {
num_cmyk++;
if (output_comp_num != GX_DEVICE_COLOR_MAX_COMPONENTS)
num_cmyk_used++;
}
}
/*
* Check if the device supports only CMYK. Otherewise we assume that
* the output device supports spot colors. Note: This algorithm can
* be fooled if the SeparationOrder device parameter is being used by
* the output device device to only select CMYK.
*/
if (num_cmyk_used == 4 && pdev->color_info.num_components == 4
&& pdev->color_info.max_components == 4) {
if (valid_blend_cs) {
*using_blend_cs = true;
switch (dev_profile->blend_profile->num_comps) {
case 1:
return PDF14_DeviceGray;
case 3:
return PDF14_DeviceRGB;
case 4:
return PDF14_DeviceCMYK;
}
}
return PDF14_DeviceCMYK;
}
/*
* Check if we should use the 'custom' PDF 1.4 compositor device.
* This device is only needed for those devices which do not support
* a basic CMYK process color model.
*/
#if CUSTOM_BLENDING_MODE == AUTO_USE_CUSTOM_BLENDING
if (num_cmyk != 4)
return PDF14_DeviceCustom;
#endif
/*
* Otherewise we use a CMYK plus spot colors for blending.
*/
return PDF14_DeviceCMYKspot;
}
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,354
|
pdf14_disable_device(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
if_debug0m('v', dev->memory, "[v]pdf14_disable_device\n");
dev->color_info = pdev->target->color_info;
pdf14_forward_device_procs(dev);
set_dev_proc(dev, create_compositor, pdf14_forward_create_compositor);
return 0;
}
| null | 0
|
pdf14_disable_device(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
if_debug0m('v', dev->memory, "[v]pdf14_disable_device\n");
dev->color_info = pdev->target->color_info;
pdf14_forward_device_procs(dev);
set_dev_proc(dev, create_compositor, pdf14_forward_create_compositor);
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,355
|
pdf14_discard_trans_layer(gx_device *dev, gs_gstate * pgs)
{
pdf14_device *pdev = (pdf14_device *)dev;
/* The things that need to be cleaned up */
pdf14_ctx *ctx = pdev->ctx;
pdf14_smaskcolor_t *smaskcolor = pdev->smaskcolor;
pdf14_parent_color_t *group_procs = pdev->trans_group_parent_cmap_procs;
/* Free up the smask color */
if (smaskcolor != NULL) {
smaskcolor->ref_count = 1;
pdf14_decrement_smask_color(pgs, dev);
pdev->smaskcolor = NULL;
}
/* Free up the nested color procs and decrement the profiles */
if (group_procs != NULL) {
while (group_procs->previous != NULL)
pdf14_pop_parent_color(dev, pgs);
gs_free_object(dev->memory->stable_memory, group_procs, "pdf14_discard_trans_layer");
pdev->trans_group_parent_cmap_procs = NULL;
}
/* Start the contex clean up */
if (ctx != NULL) {
pdf14_buf *buf, *next;
pdf14_parent_color_t *procs, *prev_procs;
if (ctx->mask_stack != NULL) {
pdf14_free_mask_stack(ctx, ctx->memory);
}
/* Now the stack of buffers */
for (buf = ctx->stack; buf != NULL; buf = next) {
next = buf->saved;
gs_free_object(ctx->memory, buf->transfer_fn, "pdf14_discard_trans_layer");
gs_free_object(ctx->memory, buf->matte, "pdf14_discard_trans_layer");
gs_free_object(ctx->memory, buf->data, "pdf14_discard_trans_layer");
gs_free_object(ctx->memory, buf->backdrop, "pdf14_discard_trans_layer");
/* During the soft mask push, the mask_stack was copied (not moved) from
the ctx to the tos mask_stack. We are done with this now so it is safe
to free this one object */
gs_free_object(ctx->memory, buf->mask_stack, "pdf14_discard_trans_layer");
for (procs = buf->parent_color_info_procs; procs != NULL; procs = prev_procs) {
prev_procs = procs->previous;
gs_free_object(ctx->memory, procs, "pdf14_discard_trans_layer");
}
gs_free_object(ctx->memory, buf, "pdf14_discard_trans_layer");
}
/* Finally the context itself */
gs_free_object (ctx->memory, ctx, "pdf14_discard_trans_layer");
pdev->ctx = NULL;
}
return 0;
}
| null | 0
|
pdf14_discard_trans_layer(gx_device *dev, gs_gstate * pgs)
{
pdf14_device *pdev = (pdf14_device *)dev;
/* The things that need to be cleaned up */
pdf14_ctx *ctx = pdev->ctx;
pdf14_smaskcolor_t *smaskcolor = pdev->smaskcolor;
pdf14_parent_color_t *group_procs = pdev->trans_group_parent_cmap_procs;
/* Free up the smask color */
if (smaskcolor != NULL) {
smaskcolor->ref_count = 1;
pdf14_decrement_smask_color(pgs, dev);
pdev->smaskcolor = NULL;
}
/* Free up the nested color procs and decrement the profiles */
if (group_procs != NULL) {
while (group_procs->previous != NULL)
pdf14_pop_parent_color(dev, pgs);
gs_free_object(dev->memory->stable_memory, group_procs, "pdf14_discard_trans_layer");
pdev->trans_group_parent_cmap_procs = NULL;
}
/* Start the contex clean up */
if (ctx != NULL) {
pdf14_buf *buf, *next;
pdf14_parent_color_t *procs, *prev_procs;
if (ctx->mask_stack != NULL) {
pdf14_free_mask_stack(ctx, ctx->memory);
}
/* Now the stack of buffers */
for (buf = ctx->stack; buf != NULL; buf = next) {
next = buf->saved;
gs_free_object(ctx->memory, buf->transfer_fn, "pdf14_discard_trans_layer");
gs_free_object(ctx->memory, buf->matte, "pdf14_discard_trans_layer");
gs_free_object(ctx->memory, buf->data, "pdf14_discard_trans_layer");
gs_free_object(ctx->memory, buf->backdrop, "pdf14_discard_trans_layer");
/* During the soft mask push, the mask_stack was copied (not moved) from
the ctx to the tos mask_stack. We are done with this now so it is safe
to free this one object */
gs_free_object(ctx->memory, buf->mask_stack, "pdf14_discard_trans_layer");
for (procs = buf->parent_color_info_procs; procs != NULL; procs = prev_procs) {
prev_procs = procs->previous;
gs_free_object(ctx->memory, procs, "pdf14_discard_trans_layer");
}
gs_free_object(ctx->memory, buf, "pdf14_discard_trans_layer");
}
/* Finally the context itself */
gs_free_object (ctx->memory, ctx, "pdf14_discard_trans_layer");
pdev->ctx = NULL;
}
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,356
|
pdf14_fill_mask(gx_device * orig_dev,
const byte * data, int dx, int raster, gx_bitmap_id id,
int x, int y, int w, int h,
const gx_drawing_color * pdcolor, int depth,
gs_logical_operation_t lop, const gx_clip_path * pcpath)
{
gx_device *dev;
pdf14_device *p14dev = (pdf14_device *)orig_dev;
gx_device_clip cdev;
gx_color_tile *ptile = NULL;
int code = 0;
gs_int_rect group_rect;
gx_pattern_trans_t *fill_trans_buffer = NULL;
bool has_pattern_trans = false;
cmm_dev_profile_t *dev_profile;
if (pdcolor == NULL)
return_error(gs_error_unknownerror); /* color must be defined */
/* If we are doing a fill with a pattern that has a transparency then
go ahead and do a push and a pop of the transparency group */
if (gx_dc_is_pattern1_color(pdcolor)) {
if( gx_pattern1_get_transptr(pdcolor) != NULL) {
ptile = pdcolor->colors.pattern.p_tile;
/* Set up things in the ptile so that we get the proper
blending etc */
/* Set the blending procs and the is_additive setting based
upon the number of channels */
if (ptile->ttrans->n_chan-1 < 4) {
ptile->ttrans->blending_procs = &rgb_blending_procs;
ptile->ttrans->is_additive = true;
} else {
ptile->ttrans->blending_procs = &cmyk_blending_procs;
ptile->ttrans->is_additive = false;
}
/* Set the procs so that we use the proper filling method. */
gx_set_pattern_procs_trans((gx_device_color*) pdcolor);
/* Based upon if the tiles overlap pick the type of rect
fill that we will want to use */
if (ptile->has_overlap) {
/* This one does blending since there is tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_blend;
} else {
/* This one does no blending since there is no tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_simple;
}
/* Push the group */
group_rect.p.x = x;
group_rect.p.y = max(0,y);
group_rect.q.x = x + w;
group_rect.q.y = y + h;
if (!(w <= 0 || h <= 0)) {
code = pdf14_push_transparency_group(p14dev->ctx, &group_rect,
1, 0, 255,255, ptile->blending_mode, 0, 0,
ptile->ttrans->n_chan-1, false, NULL, NULL, NULL, NULL);
if (code < 0)
return code;
/* Set up the output buffer information now that we have
pushed the group */
fill_trans_buffer = new_pattern_trans_buff(p14dev->memory);
pdf14_get_buffer_information((gx_device *) p14dev,
fill_trans_buffer, NULL, false);
/* Store this in the appropriate place in pdcolor. This
is released later after the mask fill */
ptile->ttrans->fill_trans_buffer = fill_trans_buffer;
has_pattern_trans = true;
}
}
}
if (pcpath != 0) {
gx_make_clip_device_on_stack(&cdev, pcpath, orig_dev);
dev = (gx_device *) & cdev;
} else
dev = orig_dev;
if (depth > 1) {
/****** CAN'T DO ROP OR HALFTONE WITH ALPHA ******/
code = (*dev_proc(dev, copy_alpha))
(dev, data, dx, raster, id, x, y, w, h,
gx_dc_pure_color(pdcolor), depth);
} else {
code = pdcolor->type->fill_masked(pdcolor, data, dx, raster, id,
x, y, w, h, dev, lop, false);
}
if (has_pattern_trans) {
if (code >= 0)
code = dev_proc(dev, get_profile)(dev, &dev_profile);
if (code >= 0)
code = pdf14_pop_transparency_group(NULL, p14dev->ctx,
p14dev->blend_procs,
p14dev->color_info.num_components,
dev_profile->device_profile[0],
orig_dev);
gs_free_object(p14dev->memory, ptile->ttrans->fill_trans_buffer,
"pdf14_fill_mask");
ptile->ttrans->fill_trans_buffer = NULL; /* Avoid GC issues */
}
return code;
}
| null | 0
|
pdf14_fill_mask(gx_device * orig_dev,
const byte * data, int dx, int raster, gx_bitmap_id id,
int x, int y, int w, int h,
const gx_drawing_color * pdcolor, int depth,
gs_logical_operation_t lop, const gx_clip_path * pcpath)
{
gx_device *dev;
pdf14_device *p14dev = (pdf14_device *)orig_dev;
gx_device_clip cdev;
gx_color_tile *ptile = NULL;
int code = 0;
gs_int_rect group_rect;
gx_pattern_trans_t *fill_trans_buffer = NULL;
bool has_pattern_trans = false;
cmm_dev_profile_t *dev_profile;
if (pdcolor == NULL)
return_error(gs_error_unknownerror); /* color must be defined */
/* If we are doing a fill with a pattern that has a transparency then
go ahead and do a push and a pop of the transparency group */
if (gx_dc_is_pattern1_color(pdcolor)) {
if( gx_pattern1_get_transptr(pdcolor) != NULL) {
ptile = pdcolor->colors.pattern.p_tile;
/* Set up things in the ptile so that we get the proper
blending etc */
/* Set the blending procs and the is_additive setting based
upon the number of channels */
if (ptile->ttrans->n_chan-1 < 4) {
ptile->ttrans->blending_procs = &rgb_blending_procs;
ptile->ttrans->is_additive = true;
} else {
ptile->ttrans->blending_procs = &cmyk_blending_procs;
ptile->ttrans->is_additive = false;
}
/* Set the procs so that we use the proper filling method. */
gx_set_pattern_procs_trans((gx_device_color*) pdcolor);
/* Based upon if the tiles overlap pick the type of rect
fill that we will want to use */
if (ptile->has_overlap) {
/* This one does blending since there is tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_blend;
} else {
/* This one does no blending since there is no tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_simple;
}
/* Push the group */
group_rect.p.x = x;
group_rect.p.y = max(0,y);
group_rect.q.x = x + w;
group_rect.q.y = y + h;
if (!(w <= 0 || h <= 0)) {
code = pdf14_push_transparency_group(p14dev->ctx, &group_rect,
1, 0, 255,255, ptile->blending_mode, 0, 0,
ptile->ttrans->n_chan-1, false, NULL, NULL, NULL, NULL);
if (code < 0)
return code;
/* Set up the output buffer information now that we have
pushed the group */
fill_trans_buffer = new_pattern_trans_buff(p14dev->memory);
pdf14_get_buffer_information((gx_device *) p14dev,
fill_trans_buffer, NULL, false);
/* Store this in the appropriate place in pdcolor. This
is released later after the mask fill */
ptile->ttrans->fill_trans_buffer = fill_trans_buffer;
has_pattern_trans = true;
}
}
}
if (pcpath != 0) {
gx_make_clip_device_on_stack(&cdev, pcpath, orig_dev);
dev = (gx_device *) & cdev;
} else
dev = orig_dev;
if (depth > 1) {
/****** CAN'T DO ROP OR HALFTONE WITH ALPHA ******/
code = (*dev_proc(dev, copy_alpha))
(dev, data, dx, raster, id, x, y, w, h,
gx_dc_pure_color(pdcolor), depth);
} else {
code = pdcolor->type->fill_masked(pdcolor, data, dx, raster, id,
x, y, w, h, dev, lop, false);
}
if (has_pattern_trans) {
if (code >= 0)
code = dev_proc(dev, get_profile)(dev, &dev_profile);
if (code >= 0)
code = pdf14_pop_transparency_group(NULL, p14dev->ctx,
p14dev->blend_procs,
p14dev->color_info.num_components,
dev_profile->device_profile[0],
orig_dev);
gs_free_object(p14dev->memory, ptile->ttrans->fill_trans_buffer,
"pdf14_fill_mask");
ptile->ttrans->fill_trans_buffer = NULL; /* Avoid GC issues */
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,357
|
pdf14_fill_path(gx_device *dev, const gs_gstate *pgs,
gx_path *ppath, const gx_fill_params *params,
const gx_drawing_color *pdcolor,
const gx_clip_path *pcpath)
{
gs_gstate new_pgs = *pgs;
int code;
gs_pattern2_instance_t *pinst = NULL;
if (pdcolor == NULL)
return_error(gs_error_unknownerror); /* color must be defined */
if (gx_dc_is_pattern1_color(pdcolor)){
if( gx_pattern1_get_transptr(pdcolor) != NULL ||
gx_pattern1_clist_has_trans(pdcolor) ){
/* In this case, we need to push a transparency group
and tile the pattern color, which is stored in
a pdf14 device buffer in the ctile object memember
variable ttrans */
#if RAW_DUMP
/* Since we do not get a put_image to view what
we have do it now */
if (gx_pattern1_get_transptr(pdcolor) != NULL) {
pdf14_device * ppatdev14 =
pdcolor->colors.pattern.p_tile->ttrans->pdev14;
if (ppatdev14 != NULL) { /* can occur during clist reading */
byte *buf_ptr = ppatdev14->ctx->stack->data +
ppatdev14->ctx->stack->rect.p.y *
ppatdev14->ctx->stack->rowstride +
ppatdev14->ctx->stack->rect.p.x;
dump_raw_buffer(ppatdev14->ctx->stack->rect.q.y -
ppatdev14->ctx->stack->rect.p.y,
ppatdev14->ctx->stack->rect.q.x -
ppatdev14->ctx->stack->rect.p.x,
ppatdev14->ctx->stack->n_planes,
ppatdev14->ctx->stack->planestride,
ppatdev14->ctx->stack->rowstride,
"Pattern_Fill",buf_ptr);
global_index++;
} else {
gx_pattern_trans_t *patt_trans =
pdcolor->colors.pattern.p_tile->ttrans;
dump_raw_buffer(patt_trans->rect.q.y-patt_trans->rect.p.y,
patt_trans->rect.q.x-patt_trans->rect.p.x,
patt_trans->n_chan,
patt_trans->planestride, patt_trans->rowstride,
"Pattern_Fill_clist", patt_trans->transbytes +
patt_trans->rect.p.y * patt_trans->rowstride +
patt_trans->rect.p.x);
global_index++;
}
}
#endif
code = pdf14_tile_pattern_fill(dev, &new_pgs, ppath,
params, pdcolor, pcpath);
new_pgs.trans_device = NULL;
new_pgs.has_transparency = false;
return code;
}
}
if (gx_dc_is_pattern2_color(pdcolor)) {
pinst =
(gs_pattern2_instance_t *)pdcolor->ccolor.pattern;
pinst->saved->has_transparency = true;
/* The transparency color space operations are driven
by the pdf14 clist writer device. */
pinst->saved->trans_device = dev;
}
update_lop_for_pdf14(&new_pgs, pdcolor);
pdf14_set_marking_params(dev, pgs);
new_pgs.trans_device = dev;
new_pgs.has_transparency = true;
code = gx_default_fill_path(dev, &new_pgs, ppath, params, pdcolor, pcpath);
new_pgs.trans_device = NULL;
new_pgs.has_transparency = false;
if (pinst != NULL){
pinst->saved->trans_device = NULL;
}
return code;
}
| null | 0
|
pdf14_fill_path(gx_device *dev, const gs_gstate *pgs,
gx_path *ppath, const gx_fill_params *params,
const gx_drawing_color *pdcolor,
const gx_clip_path *pcpath)
{
gs_gstate new_pgs = *pgs;
int code;
gs_pattern2_instance_t *pinst = NULL;
if (pdcolor == NULL)
return_error(gs_error_unknownerror); /* color must be defined */
if (gx_dc_is_pattern1_color(pdcolor)){
if( gx_pattern1_get_transptr(pdcolor) != NULL ||
gx_pattern1_clist_has_trans(pdcolor) ){
/* In this case, we need to push a transparency group
and tile the pattern color, which is stored in
a pdf14 device buffer in the ctile object memember
variable ttrans */
#if RAW_DUMP
/* Since we do not get a put_image to view what
we have do it now */
if (gx_pattern1_get_transptr(pdcolor) != NULL) {
pdf14_device * ppatdev14 =
pdcolor->colors.pattern.p_tile->ttrans->pdev14;
if (ppatdev14 != NULL) { /* can occur during clist reading */
byte *buf_ptr = ppatdev14->ctx->stack->data +
ppatdev14->ctx->stack->rect.p.y *
ppatdev14->ctx->stack->rowstride +
ppatdev14->ctx->stack->rect.p.x;
dump_raw_buffer(ppatdev14->ctx->stack->rect.q.y -
ppatdev14->ctx->stack->rect.p.y,
ppatdev14->ctx->stack->rect.q.x -
ppatdev14->ctx->stack->rect.p.x,
ppatdev14->ctx->stack->n_planes,
ppatdev14->ctx->stack->planestride,
ppatdev14->ctx->stack->rowstride,
"Pattern_Fill",buf_ptr);
global_index++;
} else {
gx_pattern_trans_t *patt_trans =
pdcolor->colors.pattern.p_tile->ttrans;
dump_raw_buffer(patt_trans->rect.q.y-patt_trans->rect.p.y,
patt_trans->rect.q.x-patt_trans->rect.p.x,
patt_trans->n_chan,
patt_trans->planestride, patt_trans->rowstride,
"Pattern_Fill_clist", patt_trans->transbytes +
patt_trans->rect.p.y * patt_trans->rowstride +
patt_trans->rect.p.x);
global_index++;
}
}
#endif
code = pdf14_tile_pattern_fill(dev, &new_pgs, ppath,
params, pdcolor, pcpath);
new_pgs.trans_device = NULL;
new_pgs.has_transparency = false;
return code;
}
}
if (gx_dc_is_pattern2_color(pdcolor)) {
pinst =
(gs_pattern2_instance_t *)pdcolor->ccolor.pattern;
pinst->saved->has_transparency = true;
/* The transparency color space operations are driven
by the pdf14 clist writer device. */
pinst->saved->trans_device = dev;
}
update_lop_for_pdf14(&new_pgs, pdcolor);
pdf14_set_marking_params(dev, pgs);
new_pgs.trans_device = dev;
new_pgs.has_transparency = true;
code = gx_default_fill_path(dev, &new_pgs, ppath, params, pdcolor, pcpath);
new_pgs.trans_device = NULL;
new_pgs.has_transparency = false;
if (pinst != NULL){
pinst->saved->trans_device = NULL;
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,358
|
pdf14_forward_create_compositor(gx_device * dev, gx_device * * pcdev,
const gs_composite_t * pct, gs_gstate * pgs,
gs_memory_t * mem, gx_device *cdev)
{
pdf14_device *pdev = (pdf14_device *)dev;
gx_device * tdev = pdev->target;
gx_device * ndev;
int code;
*pcdev = dev;
if (gs_is_pdf14trans_compositor(pct)) {
const gs_pdf14trans_t * pdf14pct = (const gs_pdf14trans_t *) pct;
if (pdf14pct->params.pdf14_op == PDF14_PUSH_DEVICE)
return gx_update_pdf14_compositor(dev, pgs, pdf14pct, mem);
return 0;
}
code = dev_proc(tdev, create_compositor)(tdev, &ndev, pct, pgs, mem, cdev);
if (code < 0)
return code;
gx_device_set_target((gx_device_forward *)pdev, ndev);
return 0;
}
| null | 0
|
pdf14_forward_create_compositor(gx_device * dev, gx_device * * pcdev,
const gs_composite_t * pct, gs_gstate * pgs,
gs_memory_t * mem, gx_device *cdev)
{
pdf14_device *pdev = (pdf14_device *)dev;
gx_device * tdev = pdev->target;
gx_device * ndev;
int code;
*pcdev = dev;
if (gs_is_pdf14trans_compositor(pct)) {
const gs_pdf14trans_t * pdf14pct = (const gs_pdf14trans_t *) pct;
if (pdf14pct->params.pdf14_op == PDF14_PUSH_DEVICE)
return gx_update_pdf14_compositor(dev, pgs, pdf14pct, mem);
return 0;
}
code = dev_proc(tdev, create_compositor)(tdev, &ndev, pct, pgs, mem, cdev);
if (code < 0)
return code;
gx_device_set_target((gx_device_forward *)pdev, ndev);
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,359
|
pdf14_forward_open_device(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
gx_device * tdev = pdev->target;
int code;
/* The PDF 1.4 compositing devices must have a target */
if (tdev == 0)
return_error(gs_error_unknownerror);
if ((code = gs_opendevice(tdev)) >= 0)
gx_device_copy_params(dev, tdev);
return code;
}
| null | 0
|
pdf14_forward_open_device(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
gx_device * tdev = pdev->target;
int code;
/* The PDF 1.4 compositing devices must have a target */
if (tdev == 0)
return_error(gs_error_unknownerror);
if ((code = gs_opendevice(tdev)) >= 0)
gx_device_copy_params(dev, tdev);
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,360
|
pdf14_forward_put_params(gx_device * dev, gs_param_list * plist)
{
pdf14_device * pdev = (pdf14_device *)dev;
gx_device * tdev = pdev->target;
bool was_open = tdev->is_open;
int code = 0;
if (tdev != 0 && (code = dev_proc(tdev, put_params)(tdev, plist)) >= 0) {
gx_device_decache_colors(dev);
if (!tdev->is_open) {
code = gs_closedevice(dev);
if (code == 0)
code = was_open ? 1 : 0; /* target device closed */
}
gx_device_copy_params(dev, tdev);
}
return code;
}
| null | 0
|
pdf14_forward_put_params(gx_device * dev, gs_param_list * plist)
{
pdf14_device * pdev = (pdf14_device *)dev;
gx_device * tdev = pdev->target;
bool was_open = tdev->is_open;
int code = 0;
if (tdev != 0 && (code = dev_proc(tdev, put_params)(tdev, plist)) >= 0) {
gx_device_decache_colors(dev);
if (!tdev->is_open) {
code = gs_closedevice(dev);
if (code == 0)
code = was_open ? 1 : 0; /* target device closed */
}
gx_device_copy_params(dev, tdev);
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,361
|
static void pdf14_free_mask_stack(pdf14_ctx *ctx, gs_memory_t *memory)
{
pdf14_mask_t *mask_stack = ctx->mask_stack;
if (mask_stack->rc_mask != NULL) {
pdf14_mask_t *curr_mask = mask_stack;
pdf14_mask_t *old_mask;
while (curr_mask != NULL) {
rc_decrement(curr_mask->rc_mask, "pdf14_free_mask_stack");
old_mask = curr_mask;
curr_mask = curr_mask->previous;
gs_free_object(old_mask->memory, old_mask, "pdf14_free_mask_stack");
}
} else {
gs_free_object(memory, mask_stack, "pdf14_free_mask_stack");
}
ctx->mask_stack = NULL;
}
| null | 0
|
static void pdf14_free_mask_stack(pdf14_ctx *ctx, gs_memory_t *memory)
{
pdf14_mask_t *mask_stack = ctx->mask_stack;
if (mask_stack->rc_mask != NULL) {
pdf14_mask_t *curr_mask = mask_stack;
pdf14_mask_t *old_mask;
while (curr_mask != NULL) {
rc_decrement(curr_mask->rc_mask, "pdf14_free_mask_stack");
old_mask = curr_mask;
curr_mask = curr_mask->previous;
gs_free_object(old_mask->memory, old_mask, "pdf14_free_mask_stack");
}
} else {
gs_free_object(memory, mask_stack, "pdf14_free_mask_stack");
}
ctx->mask_stack = NULL;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,362
|
pdf14_get_buffer_information(const gx_device * dev,
gx_pattern_trans_t *transbuff, gs_memory_t *mem,
bool free_device)
{
const pdf14_device * pdev = (pdf14_device *)dev;
pdf14_buf *buf;
gs_int_rect rect;
int x1,y1,width,height;
if ( pdev->ctx == NULL){
return 0; /* this can occur if the pattern is a clist */
}
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
#endif
buf = pdev->ctx->stack;
rect = buf->rect;
transbuff->dirty = &buf->dirty;
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
width = x1 - rect.p.x;
height = y1 - rect.p.y;
if (width <= 0 || height <= 0 || buf->data == NULL)
return 0;
transbuff->n_chan = buf->n_chan;
transbuff->has_tags = buf->has_tags;
transbuff->has_shape = buf->has_shape;
transbuff->width = buf->rect.q.x - buf->rect.p.x;
transbuff->height = buf->rect.q.y - buf->rect.p.y;
if (free_device) {
transbuff->pdev14 = NULL;
transbuff->rect = rect;
if ((width < transbuff->width) || (height < transbuff->height)) {
/* If the bbox is smaller than the whole buffer than go ahead and
create a new one to use. This can occur if we drew in a smaller
area than was specified by the transparency group rect. */
int rowstride = (width + 3) & -4;
int planestride = rowstride * height;
int k, j;
byte *buff_ptr_src, *buff_ptr_des;
transbuff->planestride = planestride;
transbuff->rowstride = rowstride;
transbuff->transbytes = gs_alloc_bytes(mem, planestride*(buf->n_chan + buf->has_tags ? 1 : 0),
"pdf14_get_buffer_information");
if (transbuff->transbytes == NULL)
return gs_error_VMerror;
transbuff->mem = mem;
for (j = 0; j < transbuff->n_chan; j++) {
buff_ptr_src = buf->data + j * buf->planestride +
buf->rowstride * rect.p.y + rect.p.x;
buff_ptr_des = transbuff->transbytes + j * planestride;
for (k = 0; k < height; k++) {
memcpy(buff_ptr_des, buff_ptr_src,rowstride);
buff_ptr_des += rowstride;
buff_ptr_src += buf->rowstride;
}
}
} else {
/* The entire buffer is used. Go ahead and grab the pointer and
clear the pointer in the pdf14 device data buffer so it is not
freed when we close the device */
transbuff->planestride = buf->planestride;
transbuff->rowstride = buf->rowstride;
transbuff->transbytes = buf->data;
transbuff->mem = buf->memory;
buf->data = NULL; /* So that the buffer is not freed */
}
/* Go ahead and free up the pdf14 device */
dev_proc(dev, close_device)((gx_device *)dev);
#if RAW_DUMP
/* Dump the buffer that should be going into the pattern */;
dump_raw_buffer(height, width, transbuff->n_chan,
transbuff->planestride, transbuff->rowstride,
"pdf14_pattern_buff", transbuff->transbytes);
global_index++;
#endif
} else {
/* Here we are coming from one of the fill image / pattern / mask
operations */
transbuff->pdev14 = dev;
transbuff->planestride = buf->planestride;
transbuff->rowstride = buf->rowstride;
transbuff->transbytes = buf->data;
transbuff->mem = buf->memory;
transbuff->rect = rect;
#if RAW_DUMP
/* Dump the buffer that should be going into the pattern */;
dump_raw_buffer(height, width, buf->n_chan,
pdev->ctx->stack->planestride, pdev->ctx->stack->rowstride,
"pdf14_pattern_buff", buf->data +
transbuff->rowstride * transbuff->rect.p.y +
transbuff->rect.p.x);
global_index++;
#endif
}
return(0);
}
| null | 0
|
pdf14_get_buffer_information(const gx_device * dev,
gx_pattern_trans_t *transbuff, gs_memory_t *mem,
bool free_device)
{
const pdf14_device * pdev = (pdf14_device *)dev;
pdf14_buf *buf;
gs_int_rect rect;
int x1,y1,width,height;
if ( pdev->ctx == NULL){
return 0; /* this can occur if the pattern is a clist */
}
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
#endif
buf = pdev->ctx->stack;
rect = buf->rect;
transbuff->dirty = &buf->dirty;
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
width = x1 - rect.p.x;
height = y1 - rect.p.y;
if (width <= 0 || height <= 0 || buf->data == NULL)
return 0;
transbuff->n_chan = buf->n_chan;
transbuff->has_tags = buf->has_tags;
transbuff->has_shape = buf->has_shape;
transbuff->width = buf->rect.q.x - buf->rect.p.x;
transbuff->height = buf->rect.q.y - buf->rect.p.y;
if (free_device) {
transbuff->pdev14 = NULL;
transbuff->rect = rect;
if ((width < transbuff->width) || (height < transbuff->height)) {
/* If the bbox is smaller than the whole buffer than go ahead and
create a new one to use. This can occur if we drew in a smaller
area than was specified by the transparency group rect. */
int rowstride = (width + 3) & -4;
int planestride = rowstride * height;
int k, j;
byte *buff_ptr_src, *buff_ptr_des;
transbuff->planestride = planestride;
transbuff->rowstride = rowstride;
transbuff->transbytes = gs_alloc_bytes(mem, planestride*(buf->n_chan + buf->has_tags ? 1 : 0),
"pdf14_get_buffer_information");
if (transbuff->transbytes == NULL)
return gs_error_VMerror;
transbuff->mem = mem;
for (j = 0; j < transbuff->n_chan; j++) {
buff_ptr_src = buf->data + j * buf->planestride +
buf->rowstride * rect.p.y + rect.p.x;
buff_ptr_des = transbuff->transbytes + j * planestride;
for (k = 0; k < height; k++) {
memcpy(buff_ptr_des, buff_ptr_src,rowstride);
buff_ptr_des += rowstride;
buff_ptr_src += buf->rowstride;
}
}
} else {
/* The entire buffer is used. Go ahead and grab the pointer and
clear the pointer in the pdf14 device data buffer so it is not
freed when we close the device */
transbuff->planestride = buf->planestride;
transbuff->rowstride = buf->rowstride;
transbuff->transbytes = buf->data;
transbuff->mem = buf->memory;
buf->data = NULL; /* So that the buffer is not freed */
}
/* Go ahead and free up the pdf14 device */
dev_proc(dev, close_device)((gx_device *)dev);
#if RAW_DUMP
/* Dump the buffer that should be going into the pattern */;
dump_raw_buffer(height, width, transbuff->n_chan,
transbuff->planestride, transbuff->rowstride,
"pdf14_pattern_buff", transbuff->transbytes);
global_index++;
#endif
} else {
/* Here we are coming from one of the fill image / pattern / mask
operations */
transbuff->pdev14 = dev;
transbuff->planestride = buf->planestride;
transbuff->rowstride = buf->rowstride;
transbuff->transbytes = buf->data;
transbuff->mem = buf->memory;
transbuff->rect = rect;
#if RAW_DUMP
/* Dump the buffer that should be going into the pattern */;
dump_raw_buffer(height, width, buf->n_chan,
pdev->ctx->stack->planestride, pdev->ctx->stack->rowstride,
"pdf14_pattern_buff", buf->data +
transbuff->rowstride * transbuff->rect.p.y +
transbuff->rect.p.x);
global_index++;
#endif
}
return(0);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,363
|
pdf14_grayspot_get_color_mapping_procs(const gx_device * dev)
{
return &pdf14_DeviceGrayspot_procs;
}
| null | 0
|
pdf14_grayspot_get_color_mapping_procs(const gx_device * dev)
{
return &pdf14_DeviceGrayspot_procs;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,364
|
pdf14_mask_element_new(gs_memory_t *memory)
{
pdf14_mask_t *result;
result = gs_alloc_struct(memory, pdf14_mask_t, &st_pdf14_mask,
"pdf14_mask_element_new");
/* Get the reference counted mask */
result->rc_mask = NULL;
result->previous = NULL;
result->memory = memory;
return(result);
}
| null | 0
|
pdf14_mask_element_new(gs_memory_t *memory)
{
pdf14_mask_t *result;
result = gs_alloc_struct(memory, pdf14_mask_t, &st_pdf14_mask,
"pdf14_mask_element_new");
/* Get the reference counted mask */
result->rc_mask = NULL;
result->previous = NULL;
result->memory = memory;
return(result);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,365
|
pdf14_open(gx_device *dev)
{
pdf14_device *pdev = (pdf14_device *)dev;
gs_int_rect rect;
if_debug2m('v', dev->memory, "[v]pdf14_open: width = %d, height = %d\n",
dev->width, dev->height);
rect.p.x = 0;
rect.p.y = 0;
rect.q.x = dev->width;
rect.q.y = dev->height;
/* If we are reenabling the device dont create a new ctx. Bug 697456 */
if (pdev->ctx == NULL)
pdev->ctx = pdf14_ctx_new(&rect, dev->color_info.num_components,
pdev->color_info.polarity != GX_CINFO_POLARITY_SUBTRACTIVE, dev);
if (pdev->ctx == NULL)
return_error(gs_error_VMerror);
pdev->free_devicen = true;
pdev->text_group = PDF14_TEXTGROUP_NO_BT;
return 0;
}
| null | 0
|
pdf14_open(gx_device *dev)
{
pdf14_device *pdev = (pdf14_device *)dev;
gs_int_rect rect;
if_debug2m('v', dev->memory, "[v]pdf14_open: width = %d, height = %d\n",
dev->width, dev->height);
rect.p.x = 0;
rect.p.y = 0;
rect.q.x = dev->width;
rect.q.y = dev->height;
/* If we are reenabling the device dont create a new ctx. Bug 697456 */
if (pdev->ctx == NULL)
pdev->ctx = pdf14_ctx_new(&rect, dev->color_info.num_components,
pdev->color_info.polarity != GX_CINFO_POLARITY_SUBTRACTIVE, dev);
if (pdev->ctx == NULL)
return_error(gs_error_VMerror);
pdev->free_devicen = true;
pdev->text_group = PDF14_TEXTGROUP_NO_BT;
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,366
|
pdf14_output_page(gx_device * dev, int num_copies, int flush)
{
pdf14_device * pdev = (pdf14_device *)dev;
if (pdev->target != NULL)
return (*dev_proc(pdev->target, output_page)) (pdev->target, num_copies, flush);
return 0;
}
| null | 0
|
pdf14_output_page(gx_device * dev, int num_copies, int flush)
{
pdf14_device * pdev = (pdf14_device *)dev;
if (pdev->target != NULL)
return (*dev_proc(pdev->target, output_page)) (pdev->target, num_copies, flush);
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,367
|
pdf14_patt_trans_image_fill(gx_device * dev, const gs_gstate * pgs,
const gs_matrix *pmat, const gs_image_common_t *pic,
const gs_int_rect * prect,
const gx_drawing_color * pdcolor,
const gx_clip_path * pcpath, gs_memory_t * mem,
gx_image_enum_common_t ** pinfo)
{
const gs_image_t *pim = (const gs_image_t *)pic;
pdf14_device * p14dev = (pdf14_device *)dev;
gx_color_tile *ptile;
int code;
gs_int_rect group_rect;
gx_image_enum *penum;
gs_rect bbox_in, bbox_out;
gx_pattern_trans_t *fill_trans_buffer;
ptile = pdcolor->colors.pattern.p_tile;
/* Set up things in the ptile so that we get the proper
blending etc */
/* Set the blending procs and the is_additive setting based
upon the number of channels */
if (ptile->ttrans->n_chan-1 < 4) {
ptile->ttrans->blending_procs = &rgb_blending_procs;
ptile->ttrans->is_additive = true;
} else {
ptile->ttrans->blending_procs = &cmyk_blending_procs;
ptile->ttrans->is_additive = false;
}
/* Set the blending mode in the ptile based upon the current
setting in the gs_gstate */
ptile->blending_mode = pgs->blend_mode;
/* Based upon if the tiles overlap pick the type of rect
fill that we will want to use */
if (ptile->has_overlap) {
/* This one does blending since there is tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_blend;
} else {
/* This one does no blending since there is no tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_simple;
}
/* Set the procs so that we use the proper filling method. */
gx_set_pattern_procs_trans((gx_device_color*) pdcolor);
/* Let the imaging stuff get set up */
code = gx_default_begin_typed_image(dev, pgs, pmat, pic,
prect, pdcolor,pcpath, mem, pinfo);
if (code < 0)
return code;
/* Now Push the group */
/* First apply the inverse of the image matrix to our
image size to get our bounding box. */
bbox_in.p.x = 0;
bbox_in.p.y = 0;
bbox_in.q.x = pim->Width;
bbox_in.q.y = pim->Height;
code = gs_bbox_transform_inverse(&bbox_in, &(pim->ImageMatrix),
&bbox_out);
if (code < 0)
return code;
/* That in turn will get hit by the matrix in the gs_gstate */
code = compute_group_device_int_rect(p14dev, &group_rect,
&bbox_out, (gs_gstate *)pgs);
if (code < 0)
return code;
if (!(pim->Width == 0 || pim->Height == 0)) {
if_debug2m('v', p14dev->ctx->memory,
"[v*] Pushing trans group patt_trans_image_fill, uid = %ld id = %ld \n",
ptile->uid.id, ptile->id);
code = pdf14_push_transparency_group(p14dev->ctx, &group_rect, 1, 0, 255,255,
pgs->blend_mode, 0, 0,
ptile->ttrans->n_chan-1, false, NULL,
NULL, (gs_gstate *)pgs, dev);
/* Set up the output buffer information now that we have
pushed the group */
fill_trans_buffer = new_pattern_trans_buff(pgs->memory);
pdf14_get_buffer_information(dev, fill_trans_buffer, NULL, false);
/* Store this in the appropriate place in pdcolor. This
is released later in pdf14_pattern_trans_render when
we are all done with the mask fill */
ptile->ttrans->fill_trans_buffer = fill_trans_buffer;
/* Change the renderer to handle this case so we can catch the
end. We will then pop the group and reset the pdcolor proc.
Keep the base renderer also. */
penum = (gx_image_enum *) *pinfo;
ptile->ttrans->image_render = penum->render;
penum->render = &pdf14_pattern_trans_render;
ptile->trans_group_popped = false;
}
return code;
}
| null | 0
|
pdf14_patt_trans_image_fill(gx_device * dev, const gs_gstate * pgs,
const gs_matrix *pmat, const gs_image_common_t *pic,
const gs_int_rect * prect,
const gx_drawing_color * pdcolor,
const gx_clip_path * pcpath, gs_memory_t * mem,
gx_image_enum_common_t ** pinfo)
{
const gs_image_t *pim = (const gs_image_t *)pic;
pdf14_device * p14dev = (pdf14_device *)dev;
gx_color_tile *ptile;
int code;
gs_int_rect group_rect;
gx_image_enum *penum;
gs_rect bbox_in, bbox_out;
gx_pattern_trans_t *fill_trans_buffer;
ptile = pdcolor->colors.pattern.p_tile;
/* Set up things in the ptile so that we get the proper
blending etc */
/* Set the blending procs and the is_additive setting based
upon the number of channels */
if (ptile->ttrans->n_chan-1 < 4) {
ptile->ttrans->blending_procs = &rgb_blending_procs;
ptile->ttrans->is_additive = true;
} else {
ptile->ttrans->blending_procs = &cmyk_blending_procs;
ptile->ttrans->is_additive = false;
}
/* Set the blending mode in the ptile based upon the current
setting in the gs_gstate */
ptile->blending_mode = pgs->blend_mode;
/* Based upon if the tiles overlap pick the type of rect
fill that we will want to use */
if (ptile->has_overlap) {
/* This one does blending since there is tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_blend;
} else {
/* This one does no blending since there is no tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_simple;
}
/* Set the procs so that we use the proper filling method. */
gx_set_pattern_procs_trans((gx_device_color*) pdcolor);
/* Let the imaging stuff get set up */
code = gx_default_begin_typed_image(dev, pgs, pmat, pic,
prect, pdcolor,pcpath, mem, pinfo);
if (code < 0)
return code;
/* Now Push the group */
/* First apply the inverse of the image matrix to our
image size to get our bounding box. */
bbox_in.p.x = 0;
bbox_in.p.y = 0;
bbox_in.q.x = pim->Width;
bbox_in.q.y = pim->Height;
code = gs_bbox_transform_inverse(&bbox_in, &(pim->ImageMatrix),
&bbox_out);
if (code < 0)
return code;
/* That in turn will get hit by the matrix in the gs_gstate */
code = compute_group_device_int_rect(p14dev, &group_rect,
&bbox_out, (gs_gstate *)pgs);
if (code < 0)
return code;
if (!(pim->Width == 0 || pim->Height == 0)) {
if_debug2m('v', p14dev->ctx->memory,
"[v*] Pushing trans group patt_trans_image_fill, uid = %ld id = %ld \n",
ptile->uid.id, ptile->id);
code = pdf14_push_transparency_group(p14dev->ctx, &group_rect, 1, 0, 255,255,
pgs->blend_mode, 0, 0,
ptile->ttrans->n_chan-1, false, NULL,
NULL, (gs_gstate *)pgs, dev);
/* Set up the output buffer information now that we have
pushed the group */
fill_trans_buffer = new_pattern_trans_buff(pgs->memory);
pdf14_get_buffer_information(dev, fill_trans_buffer, NULL, false);
/* Store this in the appropriate place in pdcolor. This
is released later in pdf14_pattern_trans_render when
we are all done with the mask fill */
ptile->ttrans->fill_trans_buffer = fill_trans_buffer;
/* Change the renderer to handle this case so we can catch the
end. We will then pop the group and reset the pdcolor proc.
Keep the base renderer also. */
penum = (gx_image_enum *) *pinfo;
ptile->ttrans->image_render = penum->render;
penum->render = &pdf14_pattern_trans_render;
ptile->trans_group_popped = false;
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,368
|
pdf14_pattern_trans_render(gx_image_enum * penum, const byte * buffer, int data_x,
uint w, int h, gx_device * dev)
{
int code;
pdf14_device * p14dev;
const gs_gstate * pgs = penum->pgs;
gx_device_color * pdcolor = (penum->icolor1);
gx_color_tile *ptile = pdcolor->colors.pattern.p_tile;
/* Pass along to the original renderer */
code = (ptile->ttrans->image_render)(penum, buffer, data_x, w, h, dev);
if (code < 0)
return code;
/* On our final time through here, go ahead and pop the transparency
group and reset the procs in the device color. And free the fill
trans buffer object */
if (h == 0 && ptile->trans_group_popped == false) {
p14dev = find_pdf14_device(dev);
if (p14dev->pclist_device == NULL) {
/* Used if we are on clist writing phase. Would only
occur if we somehow failed in high level clist
image writing */
code = gs_end_transparency_group((gs_gstate *) pgs);
} else {
/* Used if we are on clist reading phase. If we had high level
image in clist */
cmm_dev_profile_t *dev_profile;
code = dev_proc(dev, get_profile)(dev, &dev_profile);
if (code < 0)
return code;
if_debug2m('v', p14dev->ctx->memory,
"[v*] Popping trans group pattern fill, uid = %ld id = %ld \n",
ptile->uid.id, ptile->id);
code = pdf14_pop_transparency_group(NULL, p14dev->ctx, p14dev->blend_procs,
p14dev->color_info.num_components, dev_profile->device_profile[0],
(gx_device *) p14dev);
}
pdcolor->colors.pattern.p_tile->trans_group_popped = true;
gs_free_object(pgs->memory, ptile->ttrans->fill_trans_buffer,
"pdf14_pattern_trans_render");
ptile->ttrans->fill_trans_buffer = NULL; /* Avoid GC issues */
}
return code;
}
| null | 0
|
pdf14_pattern_trans_render(gx_image_enum * penum, const byte * buffer, int data_x,
uint w, int h, gx_device * dev)
{
int code;
pdf14_device * p14dev;
const gs_gstate * pgs = penum->pgs;
gx_device_color * pdcolor = (penum->icolor1);
gx_color_tile *ptile = pdcolor->colors.pattern.p_tile;
/* Pass along to the original renderer */
code = (ptile->ttrans->image_render)(penum, buffer, data_x, w, h, dev);
if (code < 0)
return code;
/* On our final time through here, go ahead and pop the transparency
group and reset the procs in the device color. And free the fill
trans buffer object */
if (h == 0 && ptile->trans_group_popped == false) {
p14dev = find_pdf14_device(dev);
if (p14dev->pclist_device == NULL) {
/* Used if we are on clist writing phase. Would only
occur if we somehow failed in high level clist
image writing */
code = gs_end_transparency_group((gs_gstate *) pgs);
} else {
/* Used if we are on clist reading phase. If we had high level
image in clist */
cmm_dev_profile_t *dev_profile;
code = dev_proc(dev, get_profile)(dev, &dev_profile);
if (code < 0)
return code;
if_debug2m('v', p14dev->ctx->memory,
"[v*] Popping trans group pattern fill, uid = %ld id = %ld \n",
ptile->uid.id, ptile->id);
code = pdf14_pop_transparency_group(NULL, p14dev->ctx, p14dev->blend_procs,
p14dev->color_info.num_components, dev_profile->device_profile[0],
(gx_device *) p14dev);
}
pdcolor->colors.pattern.p_tile->trans_group_popped = true;
gs_free_object(pgs->memory, ptile->ttrans->fill_trans_buffer,
"pdf14_pattern_trans_render");
ptile->ttrans->fill_trans_buffer = NULL; /* Avoid GC issues */
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,369
|
pdf14_pop_transparency_group(gs_gstate *pgs, pdf14_ctx *ctx,
const pdf14_nonseparable_blending_procs_t * pblend_procs,
int tos_num_color_comp, cmm_profile_t *curr_icc_profile, gx_device *dev)
{
pdf14_buf *tos = ctx->stack;
pdf14_buf *nos = tos->saved;
pdf14_mask_t *mask_stack = tos->mask_stack;
pdf14_buf *maskbuf;
int x0, x1, y0, y1;
int nos_num_color_comp;
bool icc_match;
pdf14_device *pdev = (pdf14_device *)dev;
bool overprint = pdev->overprint;
gx_color_index drawn_comps = pdev->drawn_comps;
if (nos == NULL)
return_error(gs_error_unknownerror); /* Unmatched group pop */
nos_num_color_comp = nos->parent_color_info_procs->num_components - nos->num_spots;
tos_num_color_comp = tos_num_color_comp - tos->num_spots;
#ifdef DEBUG
pdf14_debug_mask_stack_state(ctx);
#endif
if (mask_stack == NULL) {
maskbuf = NULL;
} else {
maskbuf = mask_stack->rc_mask->mask_buf;
}
/* Sanitise the dirty rectangles, in case some of the drawing routines
* have made them overly large. */
rect_intersect(tos->dirty, tos->rect);
rect_intersect(nos->dirty, nos->rect);
/* dirty = the marked bbox. rect = the entire bounds of the buffer. */
/* Everything marked on tos that fits onto nos needs to be merged down. */
y0 = max(tos->dirty.p.y, nos->rect.p.y);
y1 = min(tos->dirty.q.y, nos->rect.q.y);
x0 = max(tos->dirty.p.x, nos->rect.p.x);
x1 = min(tos->dirty.q.x, nos->rect.q.x);
if (ctx->mask_stack) {
/* This can occur when we have a situation where we are ending out of
a group that has internal to it a soft mask and another group.
The soft mask left over from the previous trans group pop is put
into ctx->masbuf, since it is still active if another trans group
push occurs to use it. If one does not occur, but instead we find
ourselves popping from a parent group, then this softmask is no
longer needed. We will rc_decrement and set it to NULL. */
rc_decrement(ctx->mask_stack->rc_mask, "pdf14_pop_transparency_group");
if (ctx->mask_stack->rc_mask == NULL ){
gs_free_object(ctx->memory, ctx->mask_stack, "pdf14_pop_transparency_group");
}
ctx->mask_stack = NULL;
}
ctx->mask_stack = mask_stack; /* Restore the mask saved by pdf14_push_transparency_group. */
tos->mask_stack = NULL; /* Clean the pointer sinse the mask ownership is now passed to ctx. */
if (tos->idle)
goto exit;
if (maskbuf != NULL && maskbuf->data == NULL && maskbuf->alpha == 255)
goto exit;
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_planes,
ctx->stack->planestride, ctx->stack->rowstride,
"aaTrans_Group_Pop",ctx->stack->data);
#endif
/* Note currently if a pattern space has transparency, the ICC profile is not used
for blending purposes. Instead we rely upon the gray, rgb, or cmyk parent space.
This is partially due to the fact that pdf14_pop_transparency_group and
pdf14_push_transparnecy_group have no real ICC interaction and those are the
operations called in the tile transparency code. Instead we may want to
look at pdf14_begin_transparency_group and pdf14_end_transparency group which
is where all the ICC information is handled. We will return to look at that later */
if (nos->parent_color_info_procs->icc_profile != NULL) {
icc_match = (nos->parent_color_info_procs->icc_profile->hashcode !=
curr_icc_profile->hashcode);
} else {
/* Let the other tests make the decision if we need to transform */
icc_match = false;
}
/* If the color spaces are different and we actually did do a swap of
the procs for color */
if ((nos->parent_color_info_procs->parent_color_mapping_procs != NULL &&
nos_num_color_comp != tos_num_color_comp) || icc_match) {
if (x0 < x1 && y0 < y1) {
pdf14_buf *result;
bool did_alloc; /* We don't care here */
result = pdf14_transform_color_buffer(pgs, ctx, dev, tos, tos->data,
curr_icc_profile, nos->parent_color_info_procs->icc_profile,
tos->rect.p.x, tos->rect.p.y, tos->rect.q.x - tos->rect.p.x,
tos->rect.q.y - tos->rect.p.y, &did_alloc);
if (result == NULL)
return_error(gs_error_unknownerror); /* transform failed */
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_chan,
ctx->stack->planestride, ctx->stack->rowstride,
"aCMTrans_Group_ColorConv",ctx->stack->data);
#endif
/* compose. never do overprint in this case */
pdf14_compose_group(tos, nos, maskbuf, x0, x1, y0, y1, nos->n_chan,
nos->parent_color_info_procs->isadditive,
nos->parent_color_info_procs->parent_blending_procs,
false, drawn_comps, ctx->memory, dev);
}
} else {
/* Group color spaces are the same. No color conversions needed */
if (x0 < x1 && y0 < y1)
pdf14_compose_group(tos, nos, maskbuf, x0, x1, y0, y1, nos->n_chan,
ctx->additive, pblend_procs, overprint,
drawn_comps, ctx->memory, dev);
}
exit:
ctx->stack = nos;
/* We want to detect the cases where we have luminosity soft masks embedded
within one another. The "alpha" channel really needs to be merged into
the luminosity channel in this case. This will occur during the mask pop */
if (ctx->smask_depth > 0 && maskbuf != NULL) {
/* Set the trigger so that we will blend if not alpha. Since
we have softmasks embedded in softmasks */
ctx->smask_blend = true;
}
if_debug1m('v', ctx->memory, "[v]pop buf, idle=%d\n", tos->idle);
pdf14_buf_free(tos);
return 0;
}
| null | 0
|
pdf14_pop_transparency_group(gs_gstate *pgs, pdf14_ctx *ctx,
const pdf14_nonseparable_blending_procs_t * pblend_procs,
int tos_num_color_comp, cmm_profile_t *curr_icc_profile, gx_device *dev)
{
pdf14_buf *tos = ctx->stack;
pdf14_buf *nos = tos->saved;
pdf14_mask_t *mask_stack = tos->mask_stack;
pdf14_buf *maskbuf;
int x0, x1, y0, y1;
int nos_num_color_comp;
bool icc_match;
pdf14_device *pdev = (pdf14_device *)dev;
bool overprint = pdev->overprint;
gx_color_index drawn_comps = pdev->drawn_comps;
if (nos == NULL)
return_error(gs_error_unknownerror); /* Unmatched group pop */
nos_num_color_comp = nos->parent_color_info_procs->num_components - nos->num_spots;
tos_num_color_comp = tos_num_color_comp - tos->num_spots;
#ifdef DEBUG
pdf14_debug_mask_stack_state(ctx);
#endif
if (mask_stack == NULL) {
maskbuf = NULL;
} else {
maskbuf = mask_stack->rc_mask->mask_buf;
}
/* Sanitise the dirty rectangles, in case some of the drawing routines
* have made them overly large. */
rect_intersect(tos->dirty, tos->rect);
rect_intersect(nos->dirty, nos->rect);
/* dirty = the marked bbox. rect = the entire bounds of the buffer. */
/* Everything marked on tos that fits onto nos needs to be merged down. */
y0 = max(tos->dirty.p.y, nos->rect.p.y);
y1 = min(tos->dirty.q.y, nos->rect.q.y);
x0 = max(tos->dirty.p.x, nos->rect.p.x);
x1 = min(tos->dirty.q.x, nos->rect.q.x);
if (ctx->mask_stack) {
/* This can occur when we have a situation where we are ending out of
a group that has internal to it a soft mask and another group.
The soft mask left over from the previous trans group pop is put
into ctx->masbuf, since it is still active if another trans group
push occurs to use it. If one does not occur, but instead we find
ourselves popping from a parent group, then this softmask is no
longer needed. We will rc_decrement and set it to NULL. */
rc_decrement(ctx->mask_stack->rc_mask, "pdf14_pop_transparency_group");
if (ctx->mask_stack->rc_mask == NULL ){
gs_free_object(ctx->memory, ctx->mask_stack, "pdf14_pop_transparency_group");
}
ctx->mask_stack = NULL;
}
ctx->mask_stack = mask_stack; /* Restore the mask saved by pdf14_push_transparency_group. */
tos->mask_stack = NULL; /* Clean the pointer sinse the mask ownership is now passed to ctx. */
if (tos->idle)
goto exit;
if (maskbuf != NULL && maskbuf->data == NULL && maskbuf->alpha == 255)
goto exit;
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_planes,
ctx->stack->planestride, ctx->stack->rowstride,
"aaTrans_Group_Pop",ctx->stack->data);
#endif
/* Note currently if a pattern space has transparency, the ICC profile is not used
for blending purposes. Instead we rely upon the gray, rgb, or cmyk parent space.
This is partially due to the fact that pdf14_pop_transparency_group and
pdf14_push_transparnecy_group have no real ICC interaction and those are the
operations called in the tile transparency code. Instead we may want to
look at pdf14_begin_transparency_group and pdf14_end_transparency group which
is where all the ICC information is handled. We will return to look at that later */
if (nos->parent_color_info_procs->icc_profile != NULL) {
icc_match = (nos->parent_color_info_procs->icc_profile->hashcode !=
curr_icc_profile->hashcode);
} else {
/* Let the other tests make the decision if we need to transform */
icc_match = false;
}
/* If the color spaces are different and we actually did do a swap of
the procs for color */
if ((nos->parent_color_info_procs->parent_color_mapping_procs != NULL &&
nos_num_color_comp != tos_num_color_comp) || icc_match) {
if (x0 < x1 && y0 < y1) {
pdf14_buf *result;
bool did_alloc; /* We don't care here */
result = pdf14_transform_color_buffer(pgs, ctx, dev, tos, tos->data,
curr_icc_profile, nos->parent_color_info_procs->icc_profile,
tos->rect.p.x, tos->rect.p.y, tos->rect.q.x - tos->rect.p.x,
tos->rect.q.y - tos->rect.p.y, &did_alloc);
if (result == NULL)
return_error(gs_error_unknownerror); /* transform failed */
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_chan,
ctx->stack->planestride, ctx->stack->rowstride,
"aCMTrans_Group_ColorConv",ctx->stack->data);
#endif
/* compose. never do overprint in this case */
pdf14_compose_group(tos, nos, maskbuf, x0, x1, y0, y1, nos->n_chan,
nos->parent_color_info_procs->isadditive,
nos->parent_color_info_procs->parent_blending_procs,
false, drawn_comps, ctx->memory, dev);
}
} else {
/* Group color spaces are the same. No color conversions needed */
if (x0 < x1 && y0 < y1)
pdf14_compose_group(tos, nos, maskbuf, x0, x1, y0, y1, nos->n_chan,
ctx->additive, pblend_procs, overprint,
drawn_comps, ctx->memory, dev);
}
exit:
ctx->stack = nos;
/* We want to detect the cases where we have luminosity soft masks embedded
within one another. The "alpha" channel really needs to be merged into
the luminosity channel in this case. This will occur during the mask pop */
if (ctx->smask_depth > 0 && maskbuf != NULL) {
/* Set the trigger so that we will blend if not alpha. Since
we have softmasks embedded in softmasks */
ctx->smask_blend = true;
}
if_debug1m('v', ctx->memory, "[v]pop buf, idle=%d\n", tos->idle);
pdf14_buf_free(tos);
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,370
|
pdf14_pop_transparency_mask(pdf14_ctx *ctx, gs_gstate *pgs, gx_device *dev)
{
pdf14_buf *tos = ctx->stack;
byte *new_data_buf;
int icc_match;
cmm_profile_t *des_profile = tos->parent_color_info_procs->icc_profile; /* If set, this should be a gray profile */
cmm_profile_t *src_profile;
gsicc_rendering_param_t rendering_params;
gsicc_link_t *icc_link;
gsicc_rendering_param_t render_cond;
cmm_dev_profile_t *dev_profile;
dev_proc(dev, get_profile)(dev, &dev_profile);
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &src_profile,
&render_cond);
ctx->smask_depth -= 1;
/* icc_match == -1 means old non-icc code.
icc_match == 0 means use icc code
icc_match == 1 mean no conversion needed */
if ( des_profile != NULL && src_profile != NULL ) {
icc_match = (des_profile->hashcode == src_profile->hashcode);
} else {
icc_match = -1;
}
if_debug1m('v', ctx->memory, "[v]pdf14_pop_transparency_mask, idle=%d\n",
tos->idle);
ctx->stack = tos->saved;
tos->saved = NULL; /* To avoid issues with GC */
if (tos->mask_stack) {
/* During the soft mask push, the mask_stack was copied (not moved) from
the ctx to the tos mask_stack. We are done with this now so it is safe to
just set to NULL. However, before we do that we must perform
rc decrement to match the increment that occured was made. Also,
if this is the last ref count of the rc_mask, we should free the
buffer now since no other groups need it. */
rc_decrement(tos->mask_stack->rc_mask,
"pdf14_pop_transparency_mask(tos->mask_stack->rc_mask)");
if (tos->mask_stack->rc_mask) {
if (tos->mask_stack->rc_mask->rc.ref_count == 1){
rc_decrement(tos->mask_stack->rc_mask,
"pdf14_pop_transparency_mask(tos->mask_stack->rc_mask)");
}
}
tos->mask_stack = NULL;
}
if (tos->data == NULL ) {
/* This can occur in clist rendering if the soft mask does
not intersect the current band. It would be nice to
catch this earlier and just avoid creating the structure
to begin with. For now we need to delete the structure
that was created. Only delete if the alpha value is 255 */
if (tos->alpha == 255) {
pdf14_buf_free(tos);
if (ctx->mask_stack != NULL) {
pdf14_free_mask_stack(ctx, ctx->memory);
}
} else {
/* Assign as mask buffer */
if (ctx->mask_stack != NULL) {
pdf14_free_mask_stack(ctx, ctx->memory);
}
ctx->mask_stack = pdf14_mask_element_new(ctx->memory);
ctx->mask_stack->rc_mask = pdf14_rcmask_new(ctx->memory);
ctx->mask_stack->rc_mask->mask_buf = tos;
}
ctx->smask_blend = false; /* just in case */
} else {
/* If we are already in the source space then there is no reason
to do the transformation */
/* Lets get this to a monochrome buffer and map it to a luminance only value */
/* This will reduce our memory. We won't reuse the existing one, due */
/* Due to the fact that on certain systems we may have issues recovering */
/* the data after a resize */
new_data_buf = gs_alloc_bytes(ctx->memory, tos->planestride,
"pdf14_pop_transparency_mask");
if (new_data_buf == NULL)
return_error(gs_error_VMerror);
/* Initialize with 0. Need to do this since in Smask_Luminosity_Mapping
we won't be filling everything during the remap if it had not been
written into by the PDF14 fill rect */
memset(new_data_buf, 0, tos->planestride);
/* If the subtype was alpha, then just grab the alpha channel now
and we are all done */
if (tos->SMask_SubType == TRANSPARENCY_MASK_Alpha) {
ctx->smask_blend = false; /* not used in this case */
smask_copy(tos->rect.q.y - tos->rect.p.y,
tos->rect.q.x - tos->rect.p.x,
tos->rowstride,
(tos->data)+tos->planestride, new_data_buf);
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(tos->rect.q.y-tos->rect.p.y,
tos->rowstride, tos->n_planes,
tos->planestride, tos->rowstride,
"SMask_Pop_Alpha(Mask_Plane1)",tos->data);
global_index++;
#endif
} else {
if ( icc_match == 1 || tos->n_chan == 2) {
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(tos->rect.q.y-tos->rect.p.y,
tos->rowstride, tos->n_planes,
tos->planestride, tos->rowstride,
"SMask_Pop_Lum(Mask_Plane0)",tos->data);
global_index++;
#endif
/* There is no need to color convert. Data is already gray scale.
We just need to copy the gray plane. However it is
possible that the soft mask could have a soft mask which
would end us up with some alpha blending information
(Bug691803). In fact, according to the spec, the alpha
blending has to occur. See FTS test fts_26_2601.pdf
for an example of this. Softmask buffer is intialized
with BG values. It would be nice to keep track if buffer
ever has a alpha value not 1 so that we could detect and
avoid this blend if not needed. */
smask_blend(tos->data, tos->rect.q.x - tos->rect.p.x,
tos->rect.q.y - tos->rect.p.y, tos->rowstride,
tos->planestride);
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(tos->rect.q.y-tos->rect.p.y,
tos->rowstride, tos->n_planes,
tos->planestride, tos->rowstride,
"SMask_Pop_Lum_Post_Blend",tos->data);
global_index++;
#endif
smask_copy(tos->rect.q.y - tos->rect.p.y,
tos->rect.q.x - tos->rect.p.x,
tos->rowstride, tos->data, new_data_buf);
} else {
if ( icc_match == -1 ) {
/* The slow old fashioned way */
smask_luminosity_mapping(tos->rect.q.y - tos->rect.p.y ,
tos->rect.q.x - tos->rect.p.x,tos->n_chan,
tos->rowstride, tos->planestride,
tos->data, new_data_buf, ctx->additive, tos->SMask_SubType);
} else {
/* ICC case where we use the CMM */
/* Request the ICC link for the transform that we will need to use */
rendering_params.black_point_comp = gsBLACKPTCOMP_OFF;
rendering_params.graphics_type_tag = GS_IMAGE_TAG;
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
rendering_params.cmm = gsCMM_DEFAULT;
icc_link = gsicc_get_link_profile(pgs, dev, des_profile,
src_profile, &rendering_params, pgs->memory, false);
smask_icc(dev, tos->rect.q.y - tos->rect.p.y,
tos->rect.q.x - tos->rect.p.x,tos->n_chan,
tos->rowstride, tos->planestride,
tos->data, new_data_buf, icc_link);
/* Release the link */
gsicc_release_link(icc_link);
}
}
}
/* Free the old object, NULL test was above */
gs_free_object(ctx->memory, tos->data, "pdf14_pop_transparency_mask");
tos->data = new_data_buf;
/* Data is single channel now */
tos->n_chan = 1;
tos->n_planes = 1;
/* Assign as reference counted mask buffer */
if (ctx->mask_stack != NULL) {
/* In this case, the source file is wacky as it already had a
softmask and now is getting a replacement. We need to clean
up the softmask stack before doing this free and creating
a new stack. Bug 693312 */
pdf14_free_mask_stack(ctx, ctx->memory);
}
ctx->mask_stack = pdf14_mask_element_new(ctx->memory);
if (ctx->mask_stack == NULL)
return gs_note_error(gs_error_VMerror);
ctx->mask_stack->rc_mask = pdf14_rcmask_new(ctx->memory);
if (ctx->mask_stack->rc_mask == NULL)
return gs_note_error(gs_error_VMerror);
ctx->mask_stack->rc_mask->mask_buf = tos;
}
return 0;
}
| null | 0
|
pdf14_pop_transparency_mask(pdf14_ctx *ctx, gs_gstate *pgs, gx_device *dev)
{
pdf14_buf *tos = ctx->stack;
byte *new_data_buf;
int icc_match;
cmm_profile_t *des_profile = tos->parent_color_info_procs->icc_profile; /* If set, this should be a gray profile */
cmm_profile_t *src_profile;
gsicc_rendering_param_t rendering_params;
gsicc_link_t *icc_link;
gsicc_rendering_param_t render_cond;
cmm_dev_profile_t *dev_profile;
dev_proc(dev, get_profile)(dev, &dev_profile);
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &src_profile,
&render_cond);
ctx->smask_depth -= 1;
/* icc_match == -1 means old non-icc code.
icc_match == 0 means use icc code
icc_match == 1 mean no conversion needed */
if ( des_profile != NULL && src_profile != NULL ) {
icc_match = (des_profile->hashcode == src_profile->hashcode);
} else {
icc_match = -1;
}
if_debug1m('v', ctx->memory, "[v]pdf14_pop_transparency_mask, idle=%d\n",
tos->idle);
ctx->stack = tos->saved;
tos->saved = NULL; /* To avoid issues with GC */
if (tos->mask_stack) {
/* During the soft mask push, the mask_stack was copied (not moved) from
the ctx to the tos mask_stack. We are done with this now so it is safe to
just set to NULL. However, before we do that we must perform
rc decrement to match the increment that occured was made. Also,
if this is the last ref count of the rc_mask, we should free the
buffer now since no other groups need it. */
rc_decrement(tos->mask_stack->rc_mask,
"pdf14_pop_transparency_mask(tos->mask_stack->rc_mask)");
if (tos->mask_stack->rc_mask) {
if (tos->mask_stack->rc_mask->rc.ref_count == 1){
rc_decrement(tos->mask_stack->rc_mask,
"pdf14_pop_transparency_mask(tos->mask_stack->rc_mask)");
}
}
tos->mask_stack = NULL;
}
if (tos->data == NULL ) {
/* This can occur in clist rendering if the soft mask does
not intersect the current band. It would be nice to
catch this earlier and just avoid creating the structure
to begin with. For now we need to delete the structure
that was created. Only delete if the alpha value is 255 */
if (tos->alpha == 255) {
pdf14_buf_free(tos);
if (ctx->mask_stack != NULL) {
pdf14_free_mask_stack(ctx, ctx->memory);
}
} else {
/* Assign as mask buffer */
if (ctx->mask_stack != NULL) {
pdf14_free_mask_stack(ctx, ctx->memory);
}
ctx->mask_stack = pdf14_mask_element_new(ctx->memory);
ctx->mask_stack->rc_mask = pdf14_rcmask_new(ctx->memory);
ctx->mask_stack->rc_mask->mask_buf = tos;
}
ctx->smask_blend = false; /* just in case */
} else {
/* If we are already in the source space then there is no reason
to do the transformation */
/* Lets get this to a monochrome buffer and map it to a luminance only value */
/* This will reduce our memory. We won't reuse the existing one, due */
/* Due to the fact that on certain systems we may have issues recovering */
/* the data after a resize */
new_data_buf = gs_alloc_bytes(ctx->memory, tos->planestride,
"pdf14_pop_transparency_mask");
if (new_data_buf == NULL)
return_error(gs_error_VMerror);
/* Initialize with 0. Need to do this since in Smask_Luminosity_Mapping
we won't be filling everything during the remap if it had not been
written into by the PDF14 fill rect */
memset(new_data_buf, 0, tos->planestride);
/* If the subtype was alpha, then just grab the alpha channel now
and we are all done */
if (tos->SMask_SubType == TRANSPARENCY_MASK_Alpha) {
ctx->smask_blend = false; /* not used in this case */
smask_copy(tos->rect.q.y - tos->rect.p.y,
tos->rect.q.x - tos->rect.p.x,
tos->rowstride,
(tos->data)+tos->planestride, new_data_buf);
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(tos->rect.q.y-tos->rect.p.y,
tos->rowstride, tos->n_planes,
tos->planestride, tos->rowstride,
"SMask_Pop_Alpha(Mask_Plane1)",tos->data);
global_index++;
#endif
} else {
if ( icc_match == 1 || tos->n_chan == 2) {
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(tos->rect.q.y-tos->rect.p.y,
tos->rowstride, tos->n_planes,
tos->planestride, tos->rowstride,
"SMask_Pop_Lum(Mask_Plane0)",tos->data);
global_index++;
#endif
/* There is no need to color convert. Data is already gray scale.
We just need to copy the gray plane. However it is
possible that the soft mask could have a soft mask which
would end us up with some alpha blending information
(Bug691803). In fact, according to the spec, the alpha
blending has to occur. See FTS test fts_26_2601.pdf
for an example of this. Softmask buffer is intialized
with BG values. It would be nice to keep track if buffer
ever has a alpha value not 1 so that we could detect and
avoid this blend if not needed. */
smask_blend(tos->data, tos->rect.q.x - tos->rect.p.x,
tos->rect.q.y - tos->rect.p.y, tos->rowstride,
tos->planestride);
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(tos->rect.q.y-tos->rect.p.y,
tos->rowstride, tos->n_planes,
tos->planestride, tos->rowstride,
"SMask_Pop_Lum_Post_Blend",tos->data);
global_index++;
#endif
smask_copy(tos->rect.q.y - tos->rect.p.y,
tos->rect.q.x - tos->rect.p.x,
tos->rowstride, tos->data, new_data_buf);
} else {
if ( icc_match == -1 ) {
/* The slow old fashioned way */
smask_luminosity_mapping(tos->rect.q.y - tos->rect.p.y ,
tos->rect.q.x - tos->rect.p.x,tos->n_chan,
tos->rowstride, tos->planestride,
tos->data, new_data_buf, ctx->additive, tos->SMask_SubType);
} else {
/* ICC case where we use the CMM */
/* Request the ICC link for the transform that we will need to use */
rendering_params.black_point_comp = gsBLACKPTCOMP_OFF;
rendering_params.graphics_type_tag = GS_IMAGE_TAG;
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
rendering_params.cmm = gsCMM_DEFAULT;
icc_link = gsicc_get_link_profile(pgs, dev, des_profile,
src_profile, &rendering_params, pgs->memory, false);
smask_icc(dev, tos->rect.q.y - tos->rect.p.y,
tos->rect.q.x - tos->rect.p.x,tos->n_chan,
tos->rowstride, tos->planestride,
tos->data, new_data_buf, icc_link);
/* Release the link */
gsicc_release_link(icc_link);
}
}
}
/* Free the old object, NULL test was above */
gs_free_object(ctx->memory, tos->data, "pdf14_pop_transparency_mask");
tos->data = new_data_buf;
/* Data is single channel now */
tos->n_chan = 1;
tos->n_planes = 1;
/* Assign as reference counted mask buffer */
if (ctx->mask_stack != NULL) {
/* In this case, the source file is wacky as it already had a
softmask and now is getting a replacement. We need to clean
up the softmask stack before doing this free and creating
a new stack. Bug 693312 */
pdf14_free_mask_stack(ctx, ctx->memory);
}
ctx->mask_stack = pdf14_mask_element_new(ctx->memory);
if (ctx->mask_stack == NULL)
return gs_note_error(gs_error_VMerror);
ctx->mask_stack->rc_mask = pdf14_rcmask_new(ctx->memory);
if (ctx->mask_stack->rc_mask == NULL)
return gs_note_error(gs_error_VMerror);
ctx->mask_stack->rc_mask->mask_buf = tos;
}
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,371
|
pdf14_pop_transparency_state(gx_device *dev, gs_gstate *pgs)
{
/* Pop the soft mask. It is no longer needed. Likely due to
a Q that has occurred. */
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_ctx *ctx = pdev->ctx;
pdf14_mask_t *old_mask;
if_debug0m('v', ctx->memory, "pdf14_pop_transparency_state\n");
/* rc decrement the current link after we break it from
the list, then free the stack element. Don't do
anything if there is no mask present. */
if (ctx->mask_stack != NULL) {
old_mask = ctx->mask_stack;
ctx->mask_stack = ctx->mask_stack->previous;
if (old_mask->rc_mask) {
rc_decrement(old_mask->rc_mask, "pdf14_pop_transparency_state");
}
gs_free_object(old_mask->memory, old_mask, "pdf14_pop_transparency_state");
/* We need to have some special handling here for when we have nested
soft masks. There may be a copy in the stack that we may need to
adjust. */
if (ctx->smask_depth > 0) {
if (ctx->stack != NULL && ctx->stack->mask_stack != NULL) {
ctx->stack->mask_stack = ctx->mask_stack;
}
}
}
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
#endif
return 0;
}
| null | 0
|
pdf14_pop_transparency_state(gx_device *dev, gs_gstate *pgs)
{
/* Pop the soft mask. It is no longer needed. Likely due to
a Q that has occurred. */
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_ctx *ctx = pdev->ctx;
pdf14_mask_t *old_mask;
if_debug0m('v', ctx->memory, "pdf14_pop_transparency_state\n");
/* rc decrement the current link after we break it from
the list, then free the stack element. Don't do
anything if there is no mask present. */
if (ctx->mask_stack != NULL) {
old_mask = ctx->mask_stack;
ctx->mask_stack = ctx->mask_stack->previous;
if (old_mask->rc_mask) {
rc_decrement(old_mask->rc_mask, "pdf14_pop_transparency_state");
}
gs_free_object(old_mask->memory, old_mask, "pdf14_pop_transparency_state");
/* We need to have some special handling here for when we have nested
soft masks. There may be a copy in the stack that we may need to
adjust. */
if (ctx->smask_depth > 0) {
if (ctx->stack != NULL && ctx->stack->mask_stack != NULL) {
ctx->stack->mask_stack = ctx->mask_stack;
}
}
}
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
#endif
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,372
|
pdf14_push_text_group(gx_device *dev, gs_gstate *pgs, gx_path *path,
const gx_clip_path *pcpath, gs_blend_mode_t blend_mode, float opacity,
bool is_clist)
{
int code;
gs_transparency_group_params_t params = { 0 };
gs_rect bbox = { 0 }; /* Bounding box is set by parent */
pdf14_clist_device * pdev = (pdf14_clist_device *)dev;
/* Push a non-isolated knock-out group making sure the opacity and blend
mode are correct */
params.Isolated = false;
params.Knockout = true;
params.text_group = PDF14_TEXTGROUP_BT_PUSHED;
gs_setopacityalpha(pgs, 1.0);
gs_setblendmode(pgs, BLEND_MODE_Normal);
if (is_clist) {
code = pdf14_clist_update_params(pdev, pgs, false, NULL);
if (code < 0)
return code;
}
code = gs_begin_transparency_group(pgs, ¶ms, &bbox);
if (code < 0)
return code;
gs_setopacityalpha(pgs, opacity);
gs_setblendmode(pgs, blend_mode);
if (is_clist)
code = pdf14_clist_update_params(pdev, pgs, false, NULL);
return code;
}
| null | 0
|
pdf14_push_text_group(gx_device *dev, gs_gstate *pgs, gx_path *path,
const gx_clip_path *pcpath, gs_blend_mode_t blend_mode, float opacity,
bool is_clist)
{
int code;
gs_transparency_group_params_t params = { 0 };
gs_rect bbox = { 0 }; /* Bounding box is set by parent */
pdf14_clist_device * pdev = (pdf14_clist_device *)dev;
/* Push a non-isolated knock-out group making sure the opacity and blend
mode are correct */
params.Isolated = false;
params.Knockout = true;
params.text_group = PDF14_TEXTGROUP_BT_PUSHED;
gs_setopacityalpha(pgs, 1.0);
gs_setblendmode(pgs, BLEND_MODE_Normal);
if (is_clist) {
code = pdf14_clist_update_params(pdev, pgs, false, NULL);
if (code < 0)
return code;
}
code = gs_begin_transparency_group(pgs, ¶ms, &bbox);
if (code < 0)
return code;
gs_setopacityalpha(pgs, opacity);
gs_setblendmode(pgs, blend_mode);
if (is_clist)
code = pdf14_clist_update_params(pdev, pgs, false, NULL);
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,373
|
pdf14_push_transparency_group(pdf14_ctx *ctx, gs_int_rect *rect, bool isolated,
bool knockout, byte alpha, byte shape,
gs_blend_mode_t blend_mode, bool idle, uint mask_id,
int numcomps, bool cm_back_drop,
cmm_profile_t *group_profile,
cmm_profile_t *tos_profile, gs_gstate *pgs,
gx_device *dev)
{
pdf14_buf *tos = ctx->stack;
pdf14_buf *buf, *backdrop;
bool has_shape, has_tags;
if_debug1m('v', ctx->memory,
"[v]pdf14_push_transparency_group, idle = %d\n", idle);
/* We are going to use the shape in the knockout computation. If previous
buffer has a shape or if this is a knockout then we will have a shape here */
has_shape = tos->has_shape || tos->knockout;
/* If previous buffer has tags, then add tags here */
has_tags = tos->has_tags;
/* If the group is NOT isolated we add in the alpha_g plane. This enables
recompositing to be performed ala art_pdf_recomposite_group_8 so that
the backdrop is only included one time in the computation. */
/* Order of buffer data is color data, followed by alpha channel, followed by
shape (if present), then alpha_g (if present), then tags (if present) */
buf = pdf14_buf_new(rect, has_tags, !isolated, has_shape, idle, numcomps + 1,
tos->num_spots, ctx->memory);
if (buf == NULL)
return_error(gs_error_VMerror);
if_debug4m('v', ctx->memory,
"[v]base buf: %d x %d, %d color channels, %d planes\n",
buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
buf->isolated = isolated;
buf->knockout = knockout;
buf->alpha = alpha;
buf->shape = shape;
buf->blend_mode = blend_mode;
buf->mask_id = mask_id;
buf->mask_stack = ctx->mask_stack; /* Save because the group rendering may
set up another (nested) mask. */
ctx->mask_stack = NULL; /* Clean the mask field for rendering this group.
See pdf14_pop_transparency_group how to handle it. */
buf->saved = tos;
ctx->stack = buf;
if (buf->data == NULL)
return 0;
if (idle)
return 0;
backdrop = pdf14_find_backdrop_buf(ctx);
if (backdrop == NULL) {
/* Note, don't clear out tags set by pdf14_buf_new == GS_UNKNOWN_TAG */
memset(buf->data, 0, buf->planestride * (buf->n_chan +
(buf->has_shape ? 1 : 0) +
(buf->has_alpha_g ? 1 : 0)));
} else {
if (!buf->knockout) {
if (!cm_back_drop) {
pdf14_preserve_backdrop(buf, tos, false);
} else {
/* We must have an non-isolated group with a mismatch in color spaces.
In this case, we can't just copy the buffer but must CM it */
pdf14_preserve_backdrop_cm(buf, group_profile, tos, tos_profile,
ctx->memory, pgs, dev, false);
}
}
}
/* If knockout, we have to maintain a copy of the backdrop in case we are
drawing nonisolated groups on top of the knockout group. */
if (buf->knockout) {
buf->backdrop = gs_alloc_bytes(ctx->memory, buf->planestride * buf->n_chan,
"pdf14_push_transparency_group");
if (buf->backdrop == NULL) {
return gs_throw(gs_error_VMerror, "Knockout backdrop allocation failed");
}
if (buf->isolated) {
/* We will have opaque backdrop for non-isolated compositing */
memset(buf->backdrop, 0, buf->planestride * buf->n_chan);
} else {
/* Save knockout backdrop for non-isolated compositing */
/* Note that we need to drill down through the non-isolated groups in our
stack and make sure that we are not embedded in another knockout group */
pdf14_buf *check = tos;
pdf14_buf *child = NULL; /* Needed so we can get profile */
cmm_profile_t *prev_knockout_profile;
while (check != NULL) {
if (check->isolated)
break;
if (check->knockout) {
break;
}
child = check;
check = check->saved;
}
/* Here we need to grab a back drop from a knockout parent group and
potentially worry about color differences. */
if (check == NULL) {
prev_knockout_profile = tos_profile;
check = tos;
} else {
if (child == NULL) {
prev_knockout_profile = tos_profile;
} else {
prev_knockout_profile = child->parent_color_info_procs->icc_profile;
}
}
if (!cm_back_drop) {
pdf14_preserve_backdrop(buf, check, false);
} else {
/* We must have an non-isolated group with a mismatch in color spaces.
In this case, we can't just copy the buffer but must CM it */
pdf14_preserve_backdrop_cm(buf, group_profile, check,
prev_knockout_profile, ctx->memory, pgs,
dev, false);
}
memcpy(buf->backdrop, buf->data, buf->planestride * buf->n_chan);
}
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, buf->n_chan,
ctx->stack->planestride, ctx->stack->rowstride,
"KnockoutBackDrop", buf->backdrop);
global_index++;
#endif
} else {
buf->backdrop = NULL;
}
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_planes,
ctx->stack->planestride, ctx->stack->rowstride,
"TransGroupPush", ctx->stack->data);
global_index++;
#endif
return 0;
}
| null | 0
|
pdf14_push_transparency_group(pdf14_ctx *ctx, gs_int_rect *rect, bool isolated,
bool knockout, byte alpha, byte shape,
gs_blend_mode_t blend_mode, bool idle, uint mask_id,
int numcomps, bool cm_back_drop,
cmm_profile_t *group_profile,
cmm_profile_t *tos_profile, gs_gstate *pgs,
gx_device *dev)
{
pdf14_buf *tos = ctx->stack;
pdf14_buf *buf, *backdrop;
bool has_shape, has_tags;
if_debug1m('v', ctx->memory,
"[v]pdf14_push_transparency_group, idle = %d\n", idle);
/* We are going to use the shape in the knockout computation. If previous
buffer has a shape or if this is a knockout then we will have a shape here */
has_shape = tos->has_shape || tos->knockout;
/* If previous buffer has tags, then add tags here */
has_tags = tos->has_tags;
/* If the group is NOT isolated we add in the alpha_g plane. This enables
recompositing to be performed ala art_pdf_recomposite_group_8 so that
the backdrop is only included one time in the computation. */
/* Order of buffer data is color data, followed by alpha channel, followed by
shape (if present), then alpha_g (if present), then tags (if present) */
buf = pdf14_buf_new(rect, has_tags, !isolated, has_shape, idle, numcomps + 1,
tos->num_spots, ctx->memory);
if (buf == NULL)
return_error(gs_error_VMerror);
if_debug4m('v', ctx->memory,
"[v]base buf: %d x %d, %d color channels, %d planes\n",
buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
buf->isolated = isolated;
buf->knockout = knockout;
buf->alpha = alpha;
buf->shape = shape;
buf->blend_mode = blend_mode;
buf->mask_id = mask_id;
buf->mask_stack = ctx->mask_stack; /* Save because the group rendering may
set up another (nested) mask. */
ctx->mask_stack = NULL; /* Clean the mask field for rendering this group.
See pdf14_pop_transparency_group how to handle it. */
buf->saved = tos;
ctx->stack = buf;
if (buf->data == NULL)
return 0;
if (idle)
return 0;
backdrop = pdf14_find_backdrop_buf(ctx);
if (backdrop == NULL) {
/* Note, don't clear out tags set by pdf14_buf_new == GS_UNKNOWN_TAG */
memset(buf->data, 0, buf->planestride * (buf->n_chan +
(buf->has_shape ? 1 : 0) +
(buf->has_alpha_g ? 1 : 0)));
} else {
if (!buf->knockout) {
if (!cm_back_drop) {
pdf14_preserve_backdrop(buf, tos, false);
} else {
/* We must have an non-isolated group with a mismatch in color spaces.
In this case, we can't just copy the buffer but must CM it */
pdf14_preserve_backdrop_cm(buf, group_profile, tos, tos_profile,
ctx->memory, pgs, dev, false);
}
}
}
/* If knockout, we have to maintain a copy of the backdrop in case we are
drawing nonisolated groups on top of the knockout group. */
if (buf->knockout) {
buf->backdrop = gs_alloc_bytes(ctx->memory, buf->planestride * buf->n_chan,
"pdf14_push_transparency_group");
if (buf->backdrop == NULL) {
return gs_throw(gs_error_VMerror, "Knockout backdrop allocation failed");
}
if (buf->isolated) {
/* We will have opaque backdrop for non-isolated compositing */
memset(buf->backdrop, 0, buf->planestride * buf->n_chan);
} else {
/* Save knockout backdrop for non-isolated compositing */
/* Note that we need to drill down through the non-isolated groups in our
stack and make sure that we are not embedded in another knockout group */
pdf14_buf *check = tos;
pdf14_buf *child = NULL; /* Needed so we can get profile */
cmm_profile_t *prev_knockout_profile;
while (check != NULL) {
if (check->isolated)
break;
if (check->knockout) {
break;
}
child = check;
check = check->saved;
}
/* Here we need to grab a back drop from a knockout parent group and
potentially worry about color differences. */
if (check == NULL) {
prev_knockout_profile = tos_profile;
check = tos;
} else {
if (child == NULL) {
prev_knockout_profile = tos_profile;
} else {
prev_knockout_profile = child->parent_color_info_procs->icc_profile;
}
}
if (!cm_back_drop) {
pdf14_preserve_backdrop(buf, check, false);
} else {
/* We must have an non-isolated group with a mismatch in color spaces.
In this case, we can't just copy the buffer but must CM it */
pdf14_preserve_backdrop_cm(buf, group_profile, check,
prev_knockout_profile, ctx->memory, pgs,
dev, false);
}
memcpy(buf->backdrop, buf->data, buf->planestride * buf->n_chan);
}
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, buf->n_chan,
ctx->stack->planestride, ctx->stack->rowstride,
"KnockoutBackDrop", buf->backdrop);
global_index++;
#endif
} else {
buf->backdrop = NULL;
}
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_planes,
ctx->stack->planestride, ctx->stack->rowstride,
"TransGroupPush", ctx->stack->data);
global_index++;
#endif
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,374
|
pdf14_push_transparency_mask(pdf14_ctx *ctx, gs_int_rect *rect, byte bg_alpha,
byte *transfer_fn, bool idle, bool replacing,
uint mask_id, gs_transparency_mask_subtype_t subtype,
int numcomps, int Background_components,
const float Background[], int Matte_components,
const float Matte[], const float GrayBackground)
{
pdf14_buf *buf;
unsigned char *curr_ptr, gray;
if_debug2m('v', ctx->memory,
"[v]pdf14_push_transparency_mask, idle=%d, replacing=%d\n",
idle, replacing);
ctx->smask_depth += 1;
/* An optimization to consider is that if the SubType is Alpha
then we really should only be allocating the alpha band and
only draw with that channel. Current architecture makes that
a bit tricky. We need to create this based upon the size of
the color space + an alpha channel. NOT the device size
or the previous ctx size */
/* A mask doesnt worry about tags */
buf = pdf14_buf_new(rect, false, false, false, idle, numcomps + 1, 0,
ctx->memory);
if (buf == NULL)
return_error(gs_error_VMerror);
buf->alpha = bg_alpha;
/* fill in, but these values aren't really used */
buf->isolated = true;
buf->knockout = false;
buf->shape = 0xff;
buf->blend_mode = BLEND_MODE_Normal;
buf->transfer_fn = transfer_fn;
buf->matte_num_comps = Matte_components;
if (Matte_components) {
buf->matte = (byte *)gs_alloc_bytes(ctx->memory, sizeof(float)*Matte_components,
"pdf14_push_transparency_mask");
if (buf->matte == NULL)
return_error(gs_error_VMerror);
memcpy(buf->matte, Matte, size_of(float)*Matte_components);
}
buf->mask_id = mask_id;
/* If replacing=false, we start the mask for an image with SMask.
In this case the image's SMask temporary replaces the
mask of the containing group. Save the containing droup's mask
in buf->mask_stack */
buf->mask_stack = ctx->mask_stack;
if (buf->mask_stack){
rc_increment(buf->mask_stack->rc_mask);
}
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
if (ctx->stack->planestride > 0 ){
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_planes,
ctx->stack->planestride, ctx->stack->rowstride,
"Raw_Buf_PreSmask",ctx->stack->data);
global_index++;
}
#endif
buf->saved = ctx->stack;
ctx->stack = buf;
/* Soft Mask related information so we know how to
compute luminosity when we pop the soft mask */
buf->SMask_SubType = subtype;
if (buf->data != NULL){
/* We need to initialize it to the BC if it existed */
/* According to the spec, the CS has to be the same */
/* If the back ground component is black, then don't bother
with this. Since we are forcing the rendering to gray
earlier now, go ahead and just use the GrayBackGround color
directly. */
if ( Background_components && GrayBackground != 0.0 ) {
curr_ptr = buf->data;
gray = (unsigned char) (255.0 * GrayBackground);
memset(curr_ptr, gray, buf->planestride);
curr_ptr += buf->planestride;
/* If we have a background component that was not black, then we
need to set the alpha for this mask as if we had drawn in the
entire soft mask buffer */
memset(curr_ptr, 255, buf->planestride *(buf->n_chan - 1));
} else {
/* Compose mask with opaque background */
memset(buf->data, 0, buf->planestride * buf->n_chan);
}
}
return 0;
}
| null | 0
|
pdf14_push_transparency_mask(pdf14_ctx *ctx, gs_int_rect *rect, byte bg_alpha,
byte *transfer_fn, bool idle, bool replacing,
uint mask_id, gs_transparency_mask_subtype_t subtype,
int numcomps, int Background_components,
const float Background[], int Matte_components,
const float Matte[], const float GrayBackground)
{
pdf14_buf *buf;
unsigned char *curr_ptr, gray;
if_debug2m('v', ctx->memory,
"[v]pdf14_push_transparency_mask, idle=%d, replacing=%d\n",
idle, replacing);
ctx->smask_depth += 1;
/* An optimization to consider is that if the SubType is Alpha
then we really should only be allocating the alpha band and
only draw with that channel. Current architecture makes that
a bit tricky. We need to create this based upon the size of
the color space + an alpha channel. NOT the device size
or the previous ctx size */
/* A mask doesnt worry about tags */
buf = pdf14_buf_new(rect, false, false, false, idle, numcomps + 1, 0,
ctx->memory);
if (buf == NULL)
return_error(gs_error_VMerror);
buf->alpha = bg_alpha;
/* fill in, but these values aren't really used */
buf->isolated = true;
buf->knockout = false;
buf->shape = 0xff;
buf->blend_mode = BLEND_MODE_Normal;
buf->transfer_fn = transfer_fn;
buf->matte_num_comps = Matte_components;
if (Matte_components) {
buf->matte = (byte *)gs_alloc_bytes(ctx->memory, sizeof(float)*Matte_components,
"pdf14_push_transparency_mask");
if (buf->matte == NULL)
return_error(gs_error_VMerror);
memcpy(buf->matte, Matte, size_of(float)*Matte_components);
}
buf->mask_id = mask_id;
/* If replacing=false, we start the mask for an image with SMask.
In this case the image's SMask temporary replaces the
mask of the containing group. Save the containing droup's mask
in buf->mask_stack */
buf->mask_stack = ctx->mask_stack;
if (buf->mask_stack){
rc_increment(buf->mask_stack->rc_mask);
}
#if RAW_DUMP
/* Dump the current buffer to see what we have. */
if (ctx->stack->planestride > 0 ){
dump_raw_buffer(ctx->stack->rect.q.y-ctx->stack->rect.p.y,
ctx->stack->rowstride, ctx->stack->n_planes,
ctx->stack->planestride, ctx->stack->rowstride,
"Raw_Buf_PreSmask",ctx->stack->data);
global_index++;
}
#endif
buf->saved = ctx->stack;
ctx->stack = buf;
/* Soft Mask related information so we know how to
compute luminosity when we pop the soft mask */
buf->SMask_SubType = subtype;
if (buf->data != NULL){
/* We need to initialize it to the BC if it existed */
/* According to the spec, the CS has to be the same */
/* If the back ground component is black, then don't bother
with this. Since we are forcing the rendering to gray
earlier now, go ahead and just use the GrayBackGround color
directly. */
if ( Background_components && GrayBackground != 0.0 ) {
curr_ptr = buf->data;
gray = (unsigned char) (255.0 * GrayBackground);
memset(curr_ptr, gray, buf->planestride);
curr_ptr += buf->planestride;
/* If we have a background component that was not black, then we
need to set the alpha for this mask as if we had drawn in the
entire soft mask buffer */
memset(curr_ptr, 255, buf->planestride *(buf->n_chan - 1));
} else {
/* Compose mask with opaque background */
memset(buf->data, 0, buf->planestride * buf->n_chan);
}
}
return 0;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,375
|
pdf14_push_transparency_state(gx_device *dev, gs_gstate *pgs)
{
/* We need to push the current soft mask. We need to
be able to recover it if we draw a new one and
then obtain a Q operation ( a pop ) */
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_ctx *ctx = pdev->ctx;
pdf14_mask_t *new_mask;
if_debug0m('v', ctx->memory, "pdf14_push_transparency_state\n");
/* We need to push the current mask buffer */
/* Allocate a new element for the stack.
Don't do anything if there is no mask present.*/
if ( ctx->mask_stack != NULL ) {
new_mask = pdf14_mask_element_new(ctx->memory);
/* Duplicate and make the link */
new_mask->rc_mask = ctx->mask_stack->rc_mask;
rc_increment(new_mask->rc_mask);
new_mask->previous = ctx->mask_stack;
ctx->mask_stack = new_mask;
}
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
#endif
return(0);
}
| null | 0
|
pdf14_push_transparency_state(gx_device *dev, gs_gstate *pgs)
{
/* We need to push the current soft mask. We need to
be able to recover it if we draw a new one and
then obtain a Q operation ( a pop ) */
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_ctx *ctx = pdev->ctx;
pdf14_mask_t *new_mask;
if_debug0m('v', ctx->memory, "pdf14_push_transparency_state\n");
/* We need to push the current mask buffer */
/* Allocate a new element for the stack.
Don't do anything if there is no mask present.*/
if ( ctx->mask_stack != NULL ) {
new_mask = pdf14_mask_element_new(ctx->memory);
/* Duplicate and make the link */
new_mask->rc_mask = ctx->mask_stack->rc_mask;
rc_increment(new_mask->rc_mask);
new_mask->previous = ctx->mask_stack;
ctx->mask_stack = new_mask;
}
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
#endif
return(0);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,376
|
pdf14_put_params(gx_device * dev, gs_param_list * plist)
{
pdf14_device * pdev = (pdf14_device *)dev;
gx_device * tdev = pdev->target;
bool was_open = tdev->is_open;
int code = 0;
if (tdev != 0 && (code = dev_proc(tdev, put_params)(tdev, plist)) >= 0) {
gx_device_decache_colors(dev);
if (!tdev->is_open) {
code = gs_closedevice(dev);
if (code == 0)
code = was_open ? 1 : 0; /* target device closed */
}
gs_pdf14_device_copy_params(dev, tdev);
}
return code;
}
| null | 0
|
pdf14_put_params(gx_device * dev, gs_param_list * plist)
{
pdf14_device * pdev = (pdf14_device *)dev;
gx_device * tdev = pdev->target;
bool was_open = tdev->is_open;
int code = 0;
if (tdev != 0 && (code = dev_proc(tdev, put_params)(tdev, plist)) >= 0) {
gx_device_decache_colors(dev);
if (!tdev->is_open) {
code = gs_closedevice(dev);
if (code == 0)
code = was_open ? 1 : 0; /* target device closed */
}
gs_pdf14_device_copy_params(dev, tdev);
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,377
|
pdf14_rcmask_new(gs_memory_t *memory)
{
pdf14_rcmask_t *result;
result = gs_alloc_struct(memory, pdf14_rcmask_t, &st_pdf14_rcmask,
"pdf14_maskbuf_new");
if ( result == NULL )
return(NULL);
rc_init_free(result, memory, 1, rc_pdf14_maskbuf_free);
result->mask_buf = NULL;
result->memory = memory;
return(result);
}
| null | 0
|
pdf14_rcmask_new(gs_memory_t *memory)
{
pdf14_rcmask_t *result;
result = gs_alloc_struct(memory, pdf14_rcmask_t, &st_pdf14_rcmask,
"pdf14_maskbuf_new");
if ( result == NULL )
return(NULL);
rc_init_free(result, memory, 1, rc_pdf14_maskbuf_free);
result->mask_buf = NULL;
result->memory = memory;
return(result);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,378
|
pdf14_recreate_device(gs_memory_t *mem, gs_gstate * pgs,
gx_device * dev, const gs_pdf14trans_t * pdf14pct)
{
pdf14_device * pdev = (pdf14_device *)dev;
gx_device * target = pdev->target;
pdf14_device * dev_proto;
pdf14_device temp_dev_proto;
bool has_tags = device_encodes_tags(dev);
int code;
if_debug0m('v', dev->memory, "[v]pdf14_recreate_device\n");
/*
* We will not use the entire prototype device but we will set the
* color related info and the device procs to match the prototype.
*/
code = get_pdf14_device_proto(target, &dev_proto, &temp_dev_proto, pgs,
pdf14pct, false);
if (code < 0)
return code;
pdev->color_info = dev_proto->color_info;
pdev->pad = target->pad;
pdev->log2_align_mod = target->log2_align_mod;
pdev->is_planar = target->is_planar;
pdev->procs = dev_proto->procs;
if (has_tags) {
set_dev_proc(pdev, encode_color, pdf14_encode_color_tag);
pdev->color_info.comp_shift[pdev->color_info.num_components] = pdev->color_info.depth;
pdev->color_info.depth += 8;
}
dev->static_procs = dev_proto->static_procs;
gx_device_set_procs(dev);
gx_device_fill_in_procs(dev);
check_device_separable(dev);
return dev_proc(pdev, open_device)(dev);
}
| null | 0
|
pdf14_recreate_device(gs_memory_t *mem, gs_gstate * pgs,
gx_device * dev, const gs_pdf14trans_t * pdf14pct)
{
pdf14_device * pdev = (pdf14_device *)dev;
gx_device * target = pdev->target;
pdf14_device * dev_proto;
pdf14_device temp_dev_proto;
bool has_tags = device_encodes_tags(dev);
int code;
if_debug0m('v', dev->memory, "[v]pdf14_recreate_device\n");
/*
* We will not use the entire prototype device but we will set the
* color related info and the device procs to match the prototype.
*/
code = get_pdf14_device_proto(target, &dev_proto, &temp_dev_proto, pgs,
pdf14pct, false);
if (code < 0)
return code;
pdev->color_info = dev_proto->color_info;
pdev->pad = target->pad;
pdev->log2_align_mod = target->log2_align_mod;
pdev->is_planar = target->is_planar;
pdev->procs = dev_proto->procs;
if (has_tags) {
set_dev_proc(pdev, encode_color, pdf14_encode_color_tag);
pdev->color_info.comp_shift[pdev->color_info.num_components] = pdev->color_info.depth;
pdev->color_info.depth += 8;
}
dev->static_procs = dev_proto->static_procs;
gx_device_set_procs(dev);
gx_device_fill_in_procs(dev);
check_device_separable(dev);
return dev_proc(pdev, open_device)(dev);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,379
|
pdf14_rgbspot_get_color_mapping_procs(const gx_device * dev)
{
return &pdf14_DeviceRGBspot_procs;
}
| null | 0
|
pdf14_rgbspot_get_color_mapping_procs(const gx_device * dev)
{
return &pdf14_DeviceRGBspot_procs;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,380
|
pdf14_set_marking_params(gx_device *dev, const gs_gstate *pgs)
{
pdf14_device * pdev = (pdf14_device *)dev;
pdev->opacity = pgs->opacity.alpha;
pdev->shape = pgs->shape.alpha;
pdev->alpha = pgs->opacity.alpha * pgs->shape.alpha;
pdev->blend_mode = pgs->blend_mode;
pdev->overprint = pgs->overprint;
pdev->overprint_mode = pgs->overprint_mode;
if_debug3m('v', dev->memory,
"[v]set_marking_params, opacity = %g, shape = %g, bm = %d\n",
pdev->opacity, pdev->shape, pgs->blend_mode);
}
| null | 0
|
pdf14_set_marking_params(gx_device *dev, const gs_gstate *pgs)
{
pdf14_device * pdev = (pdf14_device *)dev;
pdev->opacity = pgs->opacity.alpha;
pdev->shape = pgs->shape.alpha;
pdev->alpha = pgs->opacity.alpha * pgs->shape.alpha;
pdev->blend_mode = pgs->blend_mode;
pdev->overprint = pgs->overprint;
pdev->overprint_mode = pgs->overprint_mode;
if_debug3m('v', dev->memory,
"[v]set_marking_params, opacity = %g, shape = %g, bm = %d\n",
pdev->opacity, pdev->shape, pgs->blend_mode);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,381
|
pdf14_stroke_path(gx_device *dev, const gs_gstate *pgs,
gx_path *ppath, const gx_stroke_params *params,
const gx_drawing_color *pdcolor,
const gx_clip_path *pcpath)
{
gs_gstate new_pgs = *pgs;
update_lop_for_pdf14(&new_pgs, pdcolor);
pdf14_set_marking_params(dev, pgs);
return gx_default_stroke_path(dev, &new_pgs, ppath, params, pdcolor,
pcpath);
}
| null | 0
|
pdf14_stroke_path(gx_device *dev, const gs_gstate *pgs,
gx_path *ppath, const gx_stroke_params *params,
const gx_drawing_color *pdcolor,
const gx_clip_path *pcpath)
{
gs_gstate new_pgs = *pgs;
update_lop_for_pdf14(&new_pgs, pdcolor);
pdf14_set_marking_params(dev, pgs);
return gx_default_stroke_path(dev, &new_pgs, ppath, params, pdcolor,
pcpath);
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,382
|
pdf14_tile_pattern_fill(gx_device * pdev, const gs_gstate * pgs,
gx_path * ppath, const gx_fill_params * params,
const gx_device_color * pdevc,
const gx_clip_path * pcpath)
{
int code;
gs_gstate *pgs_noconst = (gs_gstate *)pgs; /* Break const. */
gs_fixed_rect clip_box;
gs_fixed_rect outer_box;
pdf14_device * p14dev = (pdf14_device *)pdev;
gs_int_rect rect;
gx_clip_rect *curr_clip_rect;
gx_color_tile *ptile = NULL;
int k;
gx_pattern_trans_t *fill_trans_buffer = NULL;
gs_int_point phase; /* Needed during clist rendering for band offset */
int n_chan_tile;
gx_clip_path cpath_intersection;
gx_path path_ttrans;
gs_blend_mode_t blend_mode;
if (ppath == NULL)
return_error(gs_error_unknownerror); /* should not happen */
if (pcpath != NULL) {
code = gx_cpath_init_local_shared_nested(&cpath_intersection, pcpath, ppath->memory, 1);
} else {
(*dev_proc(pdev, get_clipping_box)) (pdev, &clip_box);
gx_cpath_init_local(&cpath_intersection, ppath->memory);
code = gx_cpath_from_rectangle(&cpath_intersection, &clip_box);
}
if (code < 0)
return code;
code = gx_cpath_intersect_with_params(&cpath_intersection, ppath,
params->rule, pgs_noconst, params);
if (code < 0)
return code;
/* One (common) case worth optimising for is where we have a pattern that
* is positioned such that only one repeat of the tile is actually
* visible. In this case, we can restrict the size of the blending group
* we need to produce to be that of the actual area of the tile that is
* used. */
ptile = pdevc->colors.pattern.p_tile;
if (ptile->ttrans != NULL)
{
if ((cpath_intersection.outer_box.p.x < 0) ||
(cpath_intersection.outer_box.p.y < 0) ||
(cpath_intersection.outer_box.q.x > int2fixed(ptile->ttrans->width)) ||
(cpath_intersection.outer_box.q.y > int2fixed(ptile->ttrans->height)))
{
/* More than one repeat of the tile would be visible, so we can't
* use the optimisation here. (Actually, this test isn't quite
* right - it actually tests whether more than the '0th' repeat
* of the tile is visible. A better test would test if just one
* repeat of the tile was visible, irrespective of which one.
* This is (hopefully) relatively rare, and would make the code
* below more complex too, so we're ignoring that for now. If it
* becomes evident that it's a case that matters we can revisit
* it.) */
} else {
/* Only the 0th repeat is visible. Restrict the size further to
* just the used area of that patch. */
gx_path_init_local(&path_ttrans, ppath->memory);
code = gx_path_add_rectangle(&path_ttrans,
int2fixed(ptile->ttrans->rect.p.x),
int2fixed(ptile->ttrans->rect.p.y),
int2fixed(ptile->ttrans->rect.q.x),
int2fixed(ptile->ttrans->rect.q.y));
if (code < 0)
return code;
code = gx_cpath_intersect(&cpath_intersection, &path_ttrans,
params->rule, pgs_noconst);
if (code < 0)
return code;
}
}
/* Now let us push a transparency group into which we are
* going to tile the pattern. */
if (ppath != NULL && code >= 0) {
pdf14_device save_pdf14_dev; /* save area for p14dev */
gx_cpath_outer_box(&cpath_intersection, &outer_box);
rect.p.x = fixed2int(outer_box.p.x);
rect.p.y = fixed2int(outer_box.p.y);
rect.q.x = fixed2int_ceiling(outer_box.q.x);
rect.q.y = fixed2int_ceiling(outer_box.q.y);
/* The color space of this group must be the same as that of the
tile. Then when we pop the group, if there is a mismatch between
the tile color space and the current context we will do the proper
conversion. In this way, we ensure that if the tile has any overlapping
occuring it will be blended in the proper manner i.e in the tile
underlying color space. */
if (ptile->cdev == NULL) {
if (ptile->ttrans == NULL)
return_error(gs_error_unknownerror); /* should not happen */
n_chan_tile = ptile->ttrans->n_chan;
} else {
n_chan_tile = ptile->cdev->common.color_info.num_components+1;
}
blend_mode = ptile->blending_mode;
memcpy(&save_pdf14_dev, p14dev, sizeof(pdf14_device));
code = pdf14_push_transparency_group(p14dev->ctx, &rect, 1, 0, 255,255,
blend_mode, 0, 0, n_chan_tile-1,
false, NULL, NULL, pgs_noconst,
pdev);
if (code < 0)
return code;
/* Set the blending procs and the is_additive setting based
upon the number of channels */
if (ptile->cdev == NULL) {
if (n_chan_tile-1 < 4) {
ptile->ttrans->blending_procs = &rgb_blending_procs;
ptile->ttrans->is_additive = true;
} else {
ptile->ttrans->blending_procs = &cmyk_blending_procs;
ptile->ttrans->is_additive = false;
}
}
/* Now lets go through the rect list and fill with the pattern */
/* First get the buffer that we will be filling */
if (ptile->cdev == NULL) {
fill_trans_buffer = new_pattern_trans_buff(pgs->memory);
pdf14_get_buffer_information(pdev, fill_trans_buffer, NULL, false);
/* Based upon if the tiles overlap pick the type of rect fill that we will
want to use */
if (ptile->has_overlap) {
/* This one does blending since there is tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_blend;
} else {
/* This one does no blending since there is no tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_simple;
}
/* fill the rectangles */
phase.x = pdevc->phase.x;
phase.y = pdevc->phase.y;
if (cpath_intersection.rect_list->list.head != NULL){
curr_clip_rect = cpath_intersection.rect_list->list.head->next;
for( k = 0; k < cpath_intersection.rect_list->list.count && code >= 0; k++){
if_debug5m('v', pgs->memory,
"[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
curr_clip_rect->xmin, curr_clip_rect->ymin,
curr_clip_rect->xmax-curr_clip_rect->xmin,
curr_clip_rect->ymax-curr_clip_rect->ymin, (int)ptile->id);
code = gx_trans_pattern_fill_rect(curr_clip_rect->xmin, curr_clip_rect->ymin,
curr_clip_rect->xmax, curr_clip_rect->ymax, ptile,
fill_trans_buffer, phase, pdev, pdevc);
curr_clip_rect = curr_clip_rect->next;
}
} else if (cpath_intersection.rect_list->list.count == 1) {
/* The case when there is just a single rect */
if_debug5m('v', pgs->memory,
"[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymin,
cpath_intersection.rect_list->list.single.xmax-
cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymax-
cpath_intersection.rect_list->list.single.ymin,
(int)ptile->id);
code = gx_trans_pattern_fill_rect(cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymin,
cpath_intersection.rect_list->list.single.xmax,
cpath_intersection.rect_list->list.single.ymax,
ptile, fill_trans_buffer, phase, pdev, pdevc);
}
} else {
/* Clist pattern with transparency. Create a clip device from our
cpath_intersection. The above non-clist case could probably be
done this way too, which will reduce the amount of code here.
That is for another day though due to time constraints*/
gx_device *dev;
gx_device_clip clipdev;
gx_make_clip_device_on_stack(&clipdev, &cpath_intersection, pdev);
dev = (gx_device *)&clipdev;
phase.x = pdevc->phase.x;
phase.y = pdevc->phase.y;
code = gx_trans_pattern_fill_rect(rect.p.x, rect.p.y, rect.q.x, rect.q.y,
ptile, fill_trans_buffer, phase,
dev, pdevc);
}
/* We're done drawing with the pattern, remove the reference to the
* pattern device
*/
p14dev->pclist_device = NULL;
if (code < 0)
return code;
/* free our buffer object */
if (fill_trans_buffer != NULL) {
gs_free_object(pgs->memory, fill_trans_buffer, "pdf14_tile_pattern_fill");
ptile->ttrans->fill_trans_buffer = NULL; /* Avoid GC issues */
}
/* pop our transparency group which will force the blending.
This was all needed for Bug 693498 */
code = pdf14_pop_transparency_group(pgs_noconst, p14dev->ctx,
p14dev->blend_procs,
p14dev->color_info.num_components,
p14dev->icc_struct->device_profile[0],
pdev);
memcpy(p14dev, &save_pdf14_dev, sizeof(pdf14_device));
p14dev->pclist_device = NULL;
}
return code;
}
| null | 0
|
pdf14_tile_pattern_fill(gx_device * pdev, const gs_gstate * pgs,
gx_path * ppath, const gx_fill_params * params,
const gx_device_color * pdevc,
const gx_clip_path * pcpath)
{
int code;
gs_gstate *pgs_noconst = (gs_gstate *)pgs; /* Break const. */
gs_fixed_rect clip_box;
gs_fixed_rect outer_box;
pdf14_device * p14dev = (pdf14_device *)pdev;
gs_int_rect rect;
gx_clip_rect *curr_clip_rect;
gx_color_tile *ptile = NULL;
int k;
gx_pattern_trans_t *fill_trans_buffer = NULL;
gs_int_point phase; /* Needed during clist rendering for band offset */
int n_chan_tile;
gx_clip_path cpath_intersection;
gx_path path_ttrans;
gs_blend_mode_t blend_mode;
if (ppath == NULL)
return_error(gs_error_unknownerror); /* should not happen */
if (pcpath != NULL) {
code = gx_cpath_init_local_shared_nested(&cpath_intersection, pcpath, ppath->memory, 1);
} else {
(*dev_proc(pdev, get_clipping_box)) (pdev, &clip_box);
gx_cpath_init_local(&cpath_intersection, ppath->memory);
code = gx_cpath_from_rectangle(&cpath_intersection, &clip_box);
}
if (code < 0)
return code;
code = gx_cpath_intersect_with_params(&cpath_intersection, ppath,
params->rule, pgs_noconst, params);
if (code < 0)
return code;
/* One (common) case worth optimising for is where we have a pattern that
* is positioned such that only one repeat of the tile is actually
* visible. In this case, we can restrict the size of the blending group
* we need to produce to be that of the actual area of the tile that is
* used. */
ptile = pdevc->colors.pattern.p_tile;
if (ptile->ttrans != NULL)
{
if ((cpath_intersection.outer_box.p.x < 0) ||
(cpath_intersection.outer_box.p.y < 0) ||
(cpath_intersection.outer_box.q.x > int2fixed(ptile->ttrans->width)) ||
(cpath_intersection.outer_box.q.y > int2fixed(ptile->ttrans->height)))
{
/* More than one repeat of the tile would be visible, so we can't
* use the optimisation here. (Actually, this test isn't quite
* right - it actually tests whether more than the '0th' repeat
* of the tile is visible. A better test would test if just one
* repeat of the tile was visible, irrespective of which one.
* This is (hopefully) relatively rare, and would make the code
* below more complex too, so we're ignoring that for now. If it
* becomes evident that it's a case that matters we can revisit
* it.) */
} else {
/* Only the 0th repeat is visible. Restrict the size further to
* just the used area of that patch. */
gx_path_init_local(&path_ttrans, ppath->memory);
code = gx_path_add_rectangle(&path_ttrans,
int2fixed(ptile->ttrans->rect.p.x),
int2fixed(ptile->ttrans->rect.p.y),
int2fixed(ptile->ttrans->rect.q.x),
int2fixed(ptile->ttrans->rect.q.y));
if (code < 0)
return code;
code = gx_cpath_intersect(&cpath_intersection, &path_ttrans,
params->rule, pgs_noconst);
if (code < 0)
return code;
}
}
/* Now let us push a transparency group into which we are
* going to tile the pattern. */
if (ppath != NULL && code >= 0) {
pdf14_device save_pdf14_dev; /* save area for p14dev */
gx_cpath_outer_box(&cpath_intersection, &outer_box);
rect.p.x = fixed2int(outer_box.p.x);
rect.p.y = fixed2int(outer_box.p.y);
rect.q.x = fixed2int_ceiling(outer_box.q.x);
rect.q.y = fixed2int_ceiling(outer_box.q.y);
/* The color space of this group must be the same as that of the
tile. Then when we pop the group, if there is a mismatch between
the tile color space and the current context we will do the proper
conversion. In this way, we ensure that if the tile has any overlapping
occuring it will be blended in the proper manner i.e in the tile
underlying color space. */
if (ptile->cdev == NULL) {
if (ptile->ttrans == NULL)
return_error(gs_error_unknownerror); /* should not happen */
n_chan_tile = ptile->ttrans->n_chan;
} else {
n_chan_tile = ptile->cdev->common.color_info.num_components+1;
}
blend_mode = ptile->blending_mode;
memcpy(&save_pdf14_dev, p14dev, sizeof(pdf14_device));
code = pdf14_push_transparency_group(p14dev->ctx, &rect, 1, 0, 255,255,
blend_mode, 0, 0, n_chan_tile-1,
false, NULL, NULL, pgs_noconst,
pdev);
if (code < 0)
return code;
/* Set the blending procs and the is_additive setting based
upon the number of channels */
if (ptile->cdev == NULL) {
if (n_chan_tile-1 < 4) {
ptile->ttrans->blending_procs = &rgb_blending_procs;
ptile->ttrans->is_additive = true;
} else {
ptile->ttrans->blending_procs = &cmyk_blending_procs;
ptile->ttrans->is_additive = false;
}
}
/* Now lets go through the rect list and fill with the pattern */
/* First get the buffer that we will be filling */
if (ptile->cdev == NULL) {
fill_trans_buffer = new_pattern_trans_buff(pgs->memory);
pdf14_get_buffer_information(pdev, fill_trans_buffer, NULL, false);
/* Based upon if the tiles overlap pick the type of rect fill that we will
want to use */
if (ptile->has_overlap) {
/* This one does blending since there is tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_blend;
} else {
/* This one does no blending since there is no tile overlap */
ptile->ttrans->pat_trans_fill = &tile_rect_trans_simple;
}
/* fill the rectangles */
phase.x = pdevc->phase.x;
phase.y = pdevc->phase.y;
if (cpath_intersection.rect_list->list.head != NULL){
curr_clip_rect = cpath_intersection.rect_list->list.head->next;
for( k = 0; k < cpath_intersection.rect_list->list.count && code >= 0; k++){
if_debug5m('v', pgs->memory,
"[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
curr_clip_rect->xmin, curr_clip_rect->ymin,
curr_clip_rect->xmax-curr_clip_rect->xmin,
curr_clip_rect->ymax-curr_clip_rect->ymin, (int)ptile->id);
code = gx_trans_pattern_fill_rect(curr_clip_rect->xmin, curr_clip_rect->ymin,
curr_clip_rect->xmax, curr_clip_rect->ymax, ptile,
fill_trans_buffer, phase, pdev, pdevc);
curr_clip_rect = curr_clip_rect->next;
}
} else if (cpath_intersection.rect_list->list.count == 1) {
/* The case when there is just a single rect */
if_debug5m('v', pgs->memory,
"[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymin,
cpath_intersection.rect_list->list.single.xmax-
cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymax-
cpath_intersection.rect_list->list.single.ymin,
(int)ptile->id);
code = gx_trans_pattern_fill_rect(cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymin,
cpath_intersection.rect_list->list.single.xmax,
cpath_intersection.rect_list->list.single.ymax,
ptile, fill_trans_buffer, phase, pdev, pdevc);
}
} else {
/* Clist pattern with transparency. Create a clip device from our
cpath_intersection. The above non-clist case could probably be
done this way too, which will reduce the amount of code here.
That is for another day though due to time constraints*/
gx_device *dev;
gx_device_clip clipdev;
gx_make_clip_device_on_stack(&clipdev, &cpath_intersection, pdev);
dev = (gx_device *)&clipdev;
phase.x = pdevc->phase.x;
phase.y = pdevc->phase.y;
code = gx_trans_pattern_fill_rect(rect.p.x, rect.p.y, rect.q.x, rect.q.y,
ptile, fill_trans_buffer, phase,
dev, pdevc);
}
/* We're done drawing with the pattern, remove the reference to the
* pattern device
*/
p14dev->pclist_device = NULL;
if (code < 0)
return code;
/* free our buffer object */
if (fill_trans_buffer != NULL) {
gs_free_object(pgs->memory, fill_trans_buffer, "pdf14_tile_pattern_fill");
ptile->ttrans->fill_trans_buffer = NULL; /* Avoid GC issues */
}
/* pop our transparency group which will force the blending.
This was all needed for Bug 693498 */
code = pdf14_pop_transparency_group(pgs_noconst, p14dev->ctx,
p14dev->blend_procs,
p14dev->color_info.num_components,
p14dev->icc_struct->device_profile[0],
pdev);
memcpy(p14dev, &save_pdf14_dev, sizeof(pdf14_device));
p14dev->pclist_device = NULL;
}
return code;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,383
|
pdf14_transform_color_buffer(gs_gstate *pgs, pdf14_ctx *ctx, gx_device *dev,
pdf14_buf *src_buf, byte *src_data, cmm_profile_t *src_profile,
cmm_profile_t *des_profile, int x0, int y0, int width, int height, bool *did_alloc)
{
gsicc_rendering_param_t rendering_params;
gsicc_link_t *icc_link;
gsicc_bufferdesc_t src_buff_desc;
gsicc_bufferdesc_t des_buff_desc;
int src_planestride = src_buf->planestride;
int src_rowstride = src_buf->rowstride;
int src_n_planes = src_buf->n_planes;
int src_n_chan = src_buf->n_chan;
int des_planestride = src_planestride;
int des_rowstride = src_rowstride;
int des_n_planes = src_n_planes;
int des_n_chan = src_n_chan;
int diff;
int k, j;
byte *des_data = NULL;
pdf14_buf *output = src_buf;
*did_alloc = false;
/* Same profile */
if (gsicc_get_hash(src_profile) == gsicc_get_hash(des_profile))
return src_buf;
/* Define the rendering intent get the link */
rendering_params.black_point_comp = gsBLACKPTCOMP_ON;
rendering_params.graphics_type_tag = GS_IMAGE_TAG;
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
rendering_params.cmm = gsCMM_DEFAULT;
icc_link = gsicc_get_link_profile(pgs, dev, src_profile, des_profile,
&rendering_params, pgs->memory, false);
if (icc_link == NULL)
return NULL;
/* If different data sizes, we have to do an allocation */
diff = des_profile->num_comps - src_profile->num_comps;
if (diff != 0) {
byte *src_ptr;
byte *des_ptr;
*did_alloc = true;
des_rowstride = (width + 3) & -4;
des_planestride = height * des_rowstride;
des_n_planes = src_n_planes + diff;
des_n_chan = src_n_chan + diff;
des_data = gs_alloc_bytes(ctx->memory, des_planestride * des_n_planes,
"pdf14_transform_color_buffer");
if (des_data == NULL)
return NULL;
/* Copy over the noncolor planes. May only be a dirty part, so have
to copy row by row */
src_ptr = src_data;
des_ptr = des_data;
for (j = 0; j < height; j++) {
for (k = 0; k < (src_n_planes - src_profile->num_comps); k++) {
memcpy(des_ptr + des_planestride * (k + des_profile->num_comps),
src_ptr + src_planestride * (k + src_profile->num_comps),
width);
}
src_ptr += src_rowstride;
des_ptr += des_rowstride;
}
} else
des_data = src_data;
/* Set up the buffer descriptors. */
gsicc_init_buffer(&src_buff_desc, src_profile->num_comps, 1, false,
false, true, src_planestride, src_rowstride, height, width);
gsicc_init_buffer(&des_buff_desc, des_profile->num_comps,
1, false, false, true, des_planestride,
des_rowstride, height, width);
/* Transform the data. Since the pdf14 device should be using RGB, CMYK or
Gray buffers, this transform does not need to worry about the cmap procs
of the target device. */
(icc_link->procs.map_buffer)(dev, icc_link, &src_buff_desc, &des_buff_desc,
src_data, des_data);
gsicc_release_link(icc_link);
output->planestride = des_planestride;
output->rowstride = des_rowstride;
output->n_planes = des_n_planes;
output->n_chan = des_n_chan;
/* If not in-place conversion, then release. */
if (des_data != src_data) {
gs_free_object(ctx->memory, output->data,
"pdf14_transform_color_buffer");
output->data = des_data;
/* Note, this is needed for case where we did a put image, as the
resulting transformed buffer may not be a full page. */
output->rect.p.x = x0;
output->rect.p.y = y0;
output->rect.q.x = x0 + width;
output->rect.q.y = y0 + height;
}
return output;
}
| null | 0
|
pdf14_transform_color_buffer(gs_gstate *pgs, pdf14_ctx *ctx, gx_device *dev,
pdf14_buf *src_buf, byte *src_data, cmm_profile_t *src_profile,
cmm_profile_t *des_profile, int x0, int y0, int width, int height, bool *did_alloc)
{
gsicc_rendering_param_t rendering_params;
gsicc_link_t *icc_link;
gsicc_bufferdesc_t src_buff_desc;
gsicc_bufferdesc_t des_buff_desc;
int src_planestride = src_buf->planestride;
int src_rowstride = src_buf->rowstride;
int src_n_planes = src_buf->n_planes;
int src_n_chan = src_buf->n_chan;
int des_planestride = src_planestride;
int des_rowstride = src_rowstride;
int des_n_planes = src_n_planes;
int des_n_chan = src_n_chan;
int diff;
int k, j;
byte *des_data = NULL;
pdf14_buf *output = src_buf;
*did_alloc = false;
/* Same profile */
if (gsicc_get_hash(src_profile) == gsicc_get_hash(des_profile))
return src_buf;
/* Define the rendering intent get the link */
rendering_params.black_point_comp = gsBLACKPTCOMP_ON;
rendering_params.graphics_type_tag = GS_IMAGE_TAG;
rendering_params.override_icc = false;
rendering_params.preserve_black = gsBKPRESNOTSPECIFIED;
rendering_params.rendering_intent = gsPERCEPTUAL;
rendering_params.cmm = gsCMM_DEFAULT;
icc_link = gsicc_get_link_profile(pgs, dev, src_profile, des_profile,
&rendering_params, pgs->memory, false);
if (icc_link == NULL)
return NULL;
/* If different data sizes, we have to do an allocation */
diff = des_profile->num_comps - src_profile->num_comps;
if (diff != 0) {
byte *src_ptr;
byte *des_ptr;
*did_alloc = true;
des_rowstride = (width + 3) & -4;
des_planestride = height * des_rowstride;
des_n_planes = src_n_planes + diff;
des_n_chan = src_n_chan + diff;
des_data = gs_alloc_bytes(ctx->memory, des_planestride * des_n_planes,
"pdf14_transform_color_buffer");
if (des_data == NULL)
return NULL;
/* Copy over the noncolor planes. May only be a dirty part, so have
to copy row by row */
src_ptr = src_data;
des_ptr = des_data;
for (j = 0; j < height; j++) {
for (k = 0; k < (src_n_planes - src_profile->num_comps); k++) {
memcpy(des_ptr + des_planestride * (k + des_profile->num_comps),
src_ptr + src_planestride * (k + src_profile->num_comps),
width);
}
src_ptr += src_rowstride;
des_ptr += des_rowstride;
}
} else
des_data = src_data;
/* Set up the buffer descriptors. */
gsicc_init_buffer(&src_buff_desc, src_profile->num_comps, 1, false,
false, true, src_planestride, src_rowstride, height, width);
gsicc_init_buffer(&des_buff_desc, des_profile->num_comps,
1, false, false, true, des_planestride,
des_rowstride, height, width);
/* Transform the data. Since the pdf14 device should be using RGB, CMYK or
Gray buffers, this transform does not need to worry about the cmap procs
of the target device. */
(icc_link->procs.map_buffer)(dev, icc_link, &src_buff_desc, &des_buff_desc,
src_data, des_data);
gsicc_release_link(icc_link);
output->planestride = des_planestride;
output->rowstride = des_rowstride;
output->n_planes = des_n_planes;
output->n_chan = des_n_chan;
/* If not in-place conversion, then release. */
if (des_data != src_data) {
gs_free_object(ctx->memory, output->data,
"pdf14_transform_color_buffer");
output->data = des_data;
/* Note, this is needed for case where we did a put image, as the
resulting transformed buffer may not be a full page. */
output->rect.p.x = x0;
output->rect.p.y = y0;
output->rect.q.x = x0 + width;
output->rect.q.y = y0 + height;
}
return output;
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,384
|
update_lop_for_pdf14(gs_gstate *pgs, const gx_drawing_color *pdcolor)
{
bool hastrans = false;
/* We'd really rather not have to set the pdf14 bit in the lop, as this
* makes other operations much slower. We have no option however, if the
* current colour involves transparency, or if it's anything other than
* a completely solid (or transparent) operation in the normal blend mode.
*/
if (pdcolor != NULL)
{
if (gx_dc_is_pattern1_color(pdcolor) &&
gx_pattern1_get_transptr(pdcolor) != NULL) {
hastrans = true;
} else if (gx_dc_is_pattern2_color(pdcolor)) {
/* FIXME: Here we assume that ALL type 2 patterns are
* transparent - this test could be better. */
hastrans = true;
}
}
/* The only idempotent blend modes are Normal, Darken and Lighten */
if ((pgs->alpha != 0xFFFF) ||
(pgs->blend_mode != BLEND_MODE_Normal && pgs->blend_mode != BLEND_MODE_Darken && pgs->blend_mode != BLEND_MODE_Lighten) ||
(pgs->opacity.alpha != 1.0) ||
(pgs->shape.alpha != 1.0) ||
(hastrans))
{
/*
* The blend operations are not idempotent. Force non-idempotent
* filling and stroking operations.
*/
pgs->log_op |= lop_pdf14;
}
}
| null | 0
|
update_lop_for_pdf14(gs_gstate *pgs, const gx_drawing_color *pdcolor)
{
bool hastrans = false;
/* We'd really rather not have to set the pdf14 bit in the lop, as this
* makes other operations much slower. We have no option however, if the
* current colour involves transparency, or if it's anything other than
* a completely solid (or transparent) operation in the normal blend mode.
*/
if (pdcolor != NULL)
{
if (gx_dc_is_pattern1_color(pdcolor) &&
gx_pattern1_get_transptr(pdcolor) != NULL) {
hastrans = true;
} else if (gx_dc_is_pattern2_color(pdcolor)) {
/* FIXME: Here we assume that ALL type 2 patterns are
* transparent - this test could be better. */
hastrans = true;
}
}
/* The only idempotent blend modes are Normal, Darken and Lighten */
if ((pgs->alpha != 0xFFFF) ||
(pgs->blend_mode != BLEND_MODE_Normal && pgs->blend_mode != BLEND_MODE_Darken && pgs->blend_mode != BLEND_MODE_Lighten) ||
(pgs->opacity.alpha != 1.0) ||
(pgs->shape.alpha != 1.0) ||
(hastrans))
{
/*
* The blend operations are not idempotent. Force non-idempotent
* filling and stroking operations.
*/
pgs->log_op |= lop_pdf14;
}
}
|
@@ -178,6 +178,7 @@ static dev_proc_fill_mask(pdf14_fill_mask);
static dev_proc_stroke_path(pdf14_stroke_path);
static dev_proc_begin_typed_image(pdf14_begin_typed_image);
static dev_proc_text_begin(pdf14_text_begin);
+static dev_proc_finish_copydevice(pdf14_finish_copydevice);
static dev_proc_create_compositor(pdf14_create_compositor);
static dev_proc_create_compositor(pdf14_forward_create_compositor);
static dev_proc_begin_transparency_group(pdf14_begin_transparency_group);
@@ -245,7 +246,7 @@ static const gx_color_map_procs *
pdf14_create_compositor, /* create_compositor */\
NULL, /* get_hardware_params */\
pdf14_text_begin, /* text_begin */\
- NULL, /* finish_copydevice */\
+ pdf14_finish_copydevice, /* finish_copydevice */\
pdf14_begin_transparency_group,\
pdf14_end_transparency_group,\
pdf14_begin_transparency_mask,\
@@ -3935,6 +3936,19 @@ pdf14_text_begin(gx_device * dev, gs_gstate * pgs,
return code;
}
+static int
+pdf14_finish_copydevice(gx_device *new_dev, const gx_device *from_dev)
+{
+ pdf14_device *pdev = (pdf14_device*)new_dev;
+
+ pdev->ctx = NULL;
+ pdev->trans_group_parent_cmap_procs = NULL;
+ pdev->smaskcolor = NULL;
+
+ /* Only allow copying the prototype. */
+ return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
+}
+
/*
* Implement copy_mono by filling lots of small rectangles.
*/
@@ -8093,6 +8107,7 @@ c_pdf14trans_clist_read_update(gs_composite_t * pcte, gx_device * cdev,
before reopening the device */
if (p14dev->ctx != NULL) {
pdf14_ctx_free(p14dev->ctx);
+ p14dev->ctx = NULL;
}
dev_proc(tdev, open_device) (tdev);
}
|
CWE-416
| null | null |
2,385
|
static inline uint8_t sr(VGACommonState *s, int idx)
{
return vbe_enabled(s) ? s->sr_vbe[idx] : s->sr[idx];
}
|
DoS
| 0
|
static inline uint8_t sr(VGACommonState *s, int idx)
{
return vbe_enabled(s) ? s->sr_vbe[idx] : s->sr[idx];
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,386
|
static int update_basic_params(VGACommonState *s)
{
int full_update;
uint32_t start_addr, line_offset, line_compare;
full_update = 0;
s->get_offsets(s, &line_offset, &start_addr, &line_compare);
if (line_offset != s->line_offset ||
start_addr != s->start_addr ||
line_compare != s->line_compare) {
s->line_offset = line_offset;
s->start_addr = start_addr;
s->line_compare = line_compare;
full_update = 1;
}
return full_update;
}
|
DoS
| 0
|
static int update_basic_params(VGACommonState *s)
{
int full_update;
uint32_t start_addr, line_offset, line_compare;
full_update = 0;
s->get_offsets(s, &line_offset, &start_addr, &line_compare);
if (line_offset != s->line_offset ||
start_addr != s->start_addr ||
line_compare != s->line_compare) {
s->line_offset = line_offset;
s->start_addr = start_addr;
s->line_compare = line_compare;
full_update = 1;
}
return full_update;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,387
|
static int update_palette16(VGACommonState *s)
{
int full_update, i;
uint32_t v, col, *palette;
full_update = 0;
palette = s->last_palette;
for(i = 0; i < 16; i++) {
v = s->ar[i];
if (s->ar[VGA_ATC_MODE] & 0x80) {
v = ((s->ar[VGA_ATC_COLOR_PAGE] & 0xf) << 4) | (v & 0xf);
} else {
v = ((s->ar[VGA_ATC_COLOR_PAGE] & 0xc) << 4) | (v & 0x3f);
}
v = v * 3;
col = rgb_to_pixel32(c6_to_8(s->palette[v]),
c6_to_8(s->palette[v + 1]),
c6_to_8(s->palette[v + 2]));
if (col != palette[i]) {
full_update = 1;
palette[i] = col;
}
}
return full_update;
}
|
DoS
| 0
|
static int update_palette16(VGACommonState *s)
{
int full_update, i;
uint32_t v, col, *palette;
full_update = 0;
palette = s->last_palette;
for(i = 0; i < 16; i++) {
v = s->ar[i];
if (s->ar[VGA_ATC_MODE] & 0x80) {
v = ((s->ar[VGA_ATC_COLOR_PAGE] & 0xf) << 4) | (v & 0xf);
} else {
v = ((s->ar[VGA_ATC_COLOR_PAGE] & 0xc) << 4) | (v & 0x3f);
}
v = v * 3;
col = rgb_to_pixel32(c6_to_8(s->palette[v]),
c6_to_8(s->palette[v + 1]),
c6_to_8(s->palette[v + 2]));
if (col != palette[i]) {
full_update = 1;
palette[i] = col;
}
}
return full_update;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,388
|
static int update_palette256(VGACommonState *s)
{
int full_update, i;
uint32_t v, col, *palette;
full_update = 0;
palette = s->last_palette;
v = 0;
for(i = 0; i < 256; i++) {
if (s->dac_8bit) {
col = rgb_to_pixel32(s->palette[v],
s->palette[v + 1],
s->palette[v + 2]);
} else {
col = rgb_to_pixel32(c6_to_8(s->palette[v]),
c6_to_8(s->palette[v + 1]),
c6_to_8(s->palette[v + 2]));
}
if (col != palette[i]) {
full_update = 1;
palette[i] = col;
}
v += 3;
}
return full_update;
}
|
DoS
| 0
|
static int update_palette256(VGACommonState *s)
{
int full_update, i;
uint32_t v, col, *palette;
full_update = 0;
palette = s->last_palette;
v = 0;
for(i = 0; i < 256; i++) {
if (s->dac_8bit) {
col = rgb_to_pixel32(s->palette[v],
s->palette[v + 1],
s->palette[v + 2]);
} else {
col = rgb_to_pixel32(c6_to_8(s->palette[v]),
c6_to_8(s->palette[v + 1]),
c6_to_8(s->palette[v + 2]));
}
if (col != palette[i]) {
full_update = 1;
palette[i] = col;
}
v += 3;
}
return full_update;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,389
|
static inline bool vbe_enabled(VGACommonState *s)
{
return s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED;
}
|
DoS
| 0
|
static inline bool vbe_enabled(VGACommonState *s)
{
return s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,390
|
static void vbe_fixup_regs(VGACommonState *s)
{
uint16_t *r = s->vbe_regs;
uint32_t bits, linelength, maxy, offset;
if (!vbe_enabled(s)) {
/* vbe is turned off -- nothing to do */
return;
}
/* check depth */
switch (r[VBE_DISPI_INDEX_BPP]) {
case 4:
case 8:
case 16:
case 24:
case 32:
bits = r[VBE_DISPI_INDEX_BPP];
break;
case 15:
bits = 16;
break;
default:
bits = r[VBE_DISPI_INDEX_BPP] = 8;
break;
}
/* check width */
r[VBE_DISPI_INDEX_XRES] &= ~7u;
if (r[VBE_DISPI_INDEX_XRES] == 0) {
r[VBE_DISPI_INDEX_XRES] = 8;
}
if (r[VBE_DISPI_INDEX_XRES] > VBE_DISPI_MAX_XRES) {
r[VBE_DISPI_INDEX_XRES] = VBE_DISPI_MAX_XRES;
}
r[VBE_DISPI_INDEX_VIRT_WIDTH] &= ~7u;
if (r[VBE_DISPI_INDEX_VIRT_WIDTH] > VBE_DISPI_MAX_XRES) {
r[VBE_DISPI_INDEX_VIRT_WIDTH] = VBE_DISPI_MAX_XRES;
}
if (r[VBE_DISPI_INDEX_VIRT_WIDTH] < r[VBE_DISPI_INDEX_XRES]) {
r[VBE_DISPI_INDEX_VIRT_WIDTH] = r[VBE_DISPI_INDEX_XRES];
}
/* check height */
linelength = r[VBE_DISPI_INDEX_VIRT_WIDTH] * bits / 8;
maxy = s->vbe_size / linelength;
if (r[VBE_DISPI_INDEX_YRES] == 0) {
r[VBE_DISPI_INDEX_YRES] = 1;
}
if (r[VBE_DISPI_INDEX_YRES] > VBE_DISPI_MAX_YRES) {
r[VBE_DISPI_INDEX_YRES] = VBE_DISPI_MAX_YRES;
}
if (r[VBE_DISPI_INDEX_YRES] > maxy) {
r[VBE_DISPI_INDEX_YRES] = maxy;
}
/* check offset */
if (r[VBE_DISPI_INDEX_X_OFFSET] > VBE_DISPI_MAX_XRES) {
r[VBE_DISPI_INDEX_X_OFFSET] = VBE_DISPI_MAX_XRES;
}
if (r[VBE_DISPI_INDEX_Y_OFFSET] > VBE_DISPI_MAX_YRES) {
r[VBE_DISPI_INDEX_Y_OFFSET] = VBE_DISPI_MAX_YRES;
}
offset = r[VBE_DISPI_INDEX_X_OFFSET] * bits / 8;
offset += r[VBE_DISPI_INDEX_Y_OFFSET] * linelength;
if (offset + r[VBE_DISPI_INDEX_YRES] * linelength > s->vbe_size) {
r[VBE_DISPI_INDEX_Y_OFFSET] = 0;
offset = r[VBE_DISPI_INDEX_X_OFFSET] * bits / 8;
if (offset + r[VBE_DISPI_INDEX_YRES] * linelength > s->vbe_size) {
r[VBE_DISPI_INDEX_X_OFFSET] = 0;
offset = 0;
}
}
/* update vga state */
r[VBE_DISPI_INDEX_VIRT_HEIGHT] = maxy;
s->vbe_line_offset = linelength;
s->vbe_start_addr = offset / 4;
}
|
DoS
| 0
|
static void vbe_fixup_regs(VGACommonState *s)
{
uint16_t *r = s->vbe_regs;
uint32_t bits, linelength, maxy, offset;
if (!vbe_enabled(s)) {
/* vbe is turned off -- nothing to do */
return;
}
/* check depth */
switch (r[VBE_DISPI_INDEX_BPP]) {
case 4:
case 8:
case 16:
case 24:
case 32:
bits = r[VBE_DISPI_INDEX_BPP];
break;
case 15:
bits = 16;
break;
default:
bits = r[VBE_DISPI_INDEX_BPP] = 8;
break;
}
/* check width */
r[VBE_DISPI_INDEX_XRES] &= ~7u;
if (r[VBE_DISPI_INDEX_XRES] == 0) {
r[VBE_DISPI_INDEX_XRES] = 8;
}
if (r[VBE_DISPI_INDEX_XRES] > VBE_DISPI_MAX_XRES) {
r[VBE_DISPI_INDEX_XRES] = VBE_DISPI_MAX_XRES;
}
r[VBE_DISPI_INDEX_VIRT_WIDTH] &= ~7u;
if (r[VBE_DISPI_INDEX_VIRT_WIDTH] > VBE_DISPI_MAX_XRES) {
r[VBE_DISPI_INDEX_VIRT_WIDTH] = VBE_DISPI_MAX_XRES;
}
if (r[VBE_DISPI_INDEX_VIRT_WIDTH] < r[VBE_DISPI_INDEX_XRES]) {
r[VBE_DISPI_INDEX_VIRT_WIDTH] = r[VBE_DISPI_INDEX_XRES];
}
/* check height */
linelength = r[VBE_DISPI_INDEX_VIRT_WIDTH] * bits / 8;
maxy = s->vbe_size / linelength;
if (r[VBE_DISPI_INDEX_YRES] == 0) {
r[VBE_DISPI_INDEX_YRES] = 1;
}
if (r[VBE_DISPI_INDEX_YRES] > VBE_DISPI_MAX_YRES) {
r[VBE_DISPI_INDEX_YRES] = VBE_DISPI_MAX_YRES;
}
if (r[VBE_DISPI_INDEX_YRES] > maxy) {
r[VBE_DISPI_INDEX_YRES] = maxy;
}
/* check offset */
if (r[VBE_DISPI_INDEX_X_OFFSET] > VBE_DISPI_MAX_XRES) {
r[VBE_DISPI_INDEX_X_OFFSET] = VBE_DISPI_MAX_XRES;
}
if (r[VBE_DISPI_INDEX_Y_OFFSET] > VBE_DISPI_MAX_YRES) {
r[VBE_DISPI_INDEX_Y_OFFSET] = VBE_DISPI_MAX_YRES;
}
offset = r[VBE_DISPI_INDEX_X_OFFSET] * bits / 8;
offset += r[VBE_DISPI_INDEX_Y_OFFSET] * linelength;
if (offset + r[VBE_DISPI_INDEX_YRES] * linelength > s->vbe_size) {
r[VBE_DISPI_INDEX_Y_OFFSET] = 0;
offset = r[VBE_DISPI_INDEX_X_OFFSET] * bits / 8;
if (offset + r[VBE_DISPI_INDEX_YRES] * linelength > s->vbe_size) {
r[VBE_DISPI_INDEX_X_OFFSET] = 0;
offset = 0;
}
}
/* update vga state */
r[VBE_DISPI_INDEX_VIRT_HEIGHT] = maxy;
s->vbe_line_offset = linelength;
s->vbe_start_addr = offset / 4;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,391
|
uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
{
VGACommonState *s = opaque;
uint32_t val;
if (s->vbe_index < VBE_DISPI_INDEX_NB) {
if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_GETCAPS) {
switch(s->vbe_index) {
/* XXX: do not hardcode ? */
case VBE_DISPI_INDEX_XRES:
val = VBE_DISPI_MAX_XRES;
break;
case VBE_DISPI_INDEX_YRES:
val = VBE_DISPI_MAX_YRES;
break;
case VBE_DISPI_INDEX_BPP:
val = VBE_DISPI_MAX_BPP;
break;
default:
val = s->vbe_regs[s->vbe_index];
break;
}
} else {
val = s->vbe_regs[s->vbe_index];
}
} else if (s->vbe_index == VBE_DISPI_INDEX_VIDEO_MEMORY_64K) {
val = s->vbe_size / (64 * 1024);
} else {
val = 0;
}
trace_vga_vbe_read(s->vbe_index, val);
return val;
}
|
DoS
| 0
|
uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr)
{
VGACommonState *s = opaque;
uint32_t val;
if (s->vbe_index < VBE_DISPI_INDEX_NB) {
if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_GETCAPS) {
switch(s->vbe_index) {
/* XXX: do not hardcode ? */
case VBE_DISPI_INDEX_XRES:
val = VBE_DISPI_MAX_XRES;
break;
case VBE_DISPI_INDEX_YRES:
val = VBE_DISPI_MAX_YRES;
break;
case VBE_DISPI_INDEX_BPP:
val = VBE_DISPI_MAX_BPP;
break;
default:
val = s->vbe_regs[s->vbe_index];
break;
}
} else {
val = s->vbe_regs[s->vbe_index];
}
} else if (s->vbe_index == VBE_DISPI_INDEX_VIDEO_MEMORY_64K) {
val = s->vbe_size / (64 * 1024);
} else {
val = 0;
}
trace_vga_vbe_read(s->vbe_index, val);
return val;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,392
|
static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
{
VGACommonState *s = opaque;
return s->vbe_index;
}
|
DoS
| 0
|
static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr)
{
VGACommonState *s = opaque;
return s->vbe_index;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,393
|
static void vbe_update_vgaregs(VGACommonState *s)
{
int h, shift_control;
if (!vbe_enabled(s)) {
/* vbe is turned off -- nothing to do */
return;
}
/* graphic mode + memory map 1 */
s->gr[VGA_GFX_MISC] = (s->gr[VGA_GFX_MISC] & ~0x0c) | 0x04 |
VGA_GR06_GRAPHICS_MODE;
s->cr[VGA_CRTC_MODE] |= 3; /* no CGA modes */
s->cr[VGA_CRTC_OFFSET] = s->vbe_line_offset >> 3;
/* width */
s->cr[VGA_CRTC_H_DISP] =
(s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
/* height (only meaningful if < 1024) */
h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
s->cr[VGA_CRTC_V_DISP_END] = h;
s->cr[VGA_CRTC_OVERFLOW] = (s->cr[VGA_CRTC_OVERFLOW] & ~0x42) |
((h >> 7) & 0x02) | ((h >> 3) & 0x40);
/* line compare to 1023 */
s->cr[VGA_CRTC_LINE_COMPARE] = 0xff;
s->cr[VGA_CRTC_OVERFLOW] |= 0x10;
s->cr[VGA_CRTC_MAX_SCAN] |= 0x40;
if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
shift_control = 0;
s->sr_vbe[VGA_SEQ_CLOCK_MODE] &= ~8; /* no double line */
} else {
shift_control = 2;
/* set chain 4 mode */
s->sr_vbe[VGA_SEQ_MEMORY_MODE] |= VGA_SR04_CHN_4M;
/* activate all planes */
s->sr_vbe[VGA_SEQ_PLANE_WRITE] |= VGA_SR02_ALL_PLANES;
}
s->gr[VGA_GFX_MODE] = (s->gr[VGA_GFX_MODE] & ~0x60) |
(shift_control << 5);
s->cr[VGA_CRTC_MAX_SCAN] &= ~0x9f; /* no double scan */
}
|
DoS
| 0
|
static void vbe_update_vgaregs(VGACommonState *s)
{
int h, shift_control;
if (!vbe_enabled(s)) {
/* vbe is turned off -- nothing to do */
return;
}
/* graphic mode + memory map 1 */
s->gr[VGA_GFX_MISC] = (s->gr[VGA_GFX_MISC] & ~0x0c) | 0x04 |
VGA_GR06_GRAPHICS_MODE;
s->cr[VGA_CRTC_MODE] |= 3; /* no CGA modes */
s->cr[VGA_CRTC_OFFSET] = s->vbe_line_offset >> 3;
/* width */
s->cr[VGA_CRTC_H_DISP] =
(s->vbe_regs[VBE_DISPI_INDEX_XRES] >> 3) - 1;
/* height (only meaningful if < 1024) */
h = s->vbe_regs[VBE_DISPI_INDEX_YRES] - 1;
s->cr[VGA_CRTC_V_DISP_END] = h;
s->cr[VGA_CRTC_OVERFLOW] = (s->cr[VGA_CRTC_OVERFLOW] & ~0x42) |
((h >> 7) & 0x02) | ((h >> 3) & 0x40);
/* line compare to 1023 */
s->cr[VGA_CRTC_LINE_COMPARE] = 0xff;
s->cr[VGA_CRTC_OVERFLOW] |= 0x10;
s->cr[VGA_CRTC_MAX_SCAN] |= 0x40;
if (s->vbe_regs[VBE_DISPI_INDEX_BPP] == 4) {
shift_control = 0;
s->sr_vbe[VGA_SEQ_CLOCK_MODE] &= ~8; /* no double line */
} else {
shift_control = 2;
/* set chain 4 mode */
s->sr_vbe[VGA_SEQ_MEMORY_MODE] |= VGA_SR04_CHN_4M;
/* activate all planes */
s->sr_vbe[VGA_SEQ_PLANE_WRITE] |= VGA_SR02_ALL_PLANES;
}
s->gr[VGA_GFX_MODE] = (s->gr[VGA_GFX_MODE] & ~0x60) |
(shift_control << 5);
s->cr[VGA_CRTC_MAX_SCAN] &= ~0x9f; /* no double scan */
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,394
|
void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate)
{
int i, j, v, b;
for(i = 0;i < 256; i++) {
v = 0;
for(j = 0; j < 8; j++) {
v |= ((i >> j) & 1) << (j * 4);
}
expand4[i] = v;
v = 0;
for(j = 0; j < 4; j++) {
v |= ((i >> (2 * j)) & 3) << (j * 4);
}
expand2[i] = v;
}
for(i = 0; i < 16; i++) {
v = 0;
for(j = 0; j < 4; j++) {
b = ((i >> j) & 1);
v |= b << (2 * j);
v |= b << (2 * j + 1);
}
expand4to8[i] = v;
}
s->vram_size_mb = uint_clamp(s->vram_size_mb, 1, 512);
s->vram_size_mb = pow2ceil(s->vram_size_mb);
s->vram_size = s->vram_size_mb << 20;
if (!s->vbe_size) {
s->vbe_size = s->vram_size;
}
s->is_vbe_vmstate = 1;
memory_region_init_ram(&s->vram, obj, "vga.vram", s->vram_size,
&error_fatal);
vmstate_register_ram(&s->vram, global_vmstate ? NULL : DEVICE(obj));
xen_register_framebuffer(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
s->get_bpp = vga_get_bpp;
s->get_offsets = vga_get_offsets;
s->get_resolution = vga_get_resolution;
s->hw_ops = &vga_ops;
switch (vga_retrace_method) {
case VGA_RETRACE_DUMB:
s->retrace = vga_dumb_retrace;
s->update_retrace_info = vga_dumb_update_retrace_info;
break;
case VGA_RETRACE_PRECISE:
s->retrace = vga_precise_retrace;
s->update_retrace_info = vga_precise_update_retrace_info;
break;
}
/*
* Set default fb endian based on target, could probably be turned
* into a device attribute set by the machine/platform to remove
* all target endian dependencies from this file.
*/
#ifdef TARGET_WORDS_BIGENDIAN
s->default_endian_fb = true;
#else
s->default_endian_fb = false;
#endif
vga_dirty_log_start(s);
}
|
DoS
| 0
|
void vga_common_init(VGACommonState *s, Object *obj, bool global_vmstate)
{
int i, j, v, b;
for(i = 0;i < 256; i++) {
v = 0;
for(j = 0; j < 8; j++) {
v |= ((i >> j) & 1) << (j * 4);
}
expand4[i] = v;
v = 0;
for(j = 0; j < 4; j++) {
v |= ((i >> (2 * j)) & 3) << (j * 4);
}
expand2[i] = v;
}
for(i = 0; i < 16; i++) {
v = 0;
for(j = 0; j < 4; j++) {
b = ((i >> j) & 1);
v |= b << (2 * j);
v |= b << (2 * j + 1);
}
expand4to8[i] = v;
}
s->vram_size_mb = uint_clamp(s->vram_size_mb, 1, 512);
s->vram_size_mb = pow2ceil(s->vram_size_mb);
s->vram_size = s->vram_size_mb << 20;
if (!s->vbe_size) {
s->vbe_size = s->vram_size;
}
s->is_vbe_vmstate = 1;
memory_region_init_ram(&s->vram, obj, "vga.vram", s->vram_size,
&error_fatal);
vmstate_register_ram(&s->vram, global_vmstate ? NULL : DEVICE(obj));
xen_register_framebuffer(&s->vram);
s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
s->get_bpp = vga_get_bpp;
s->get_offsets = vga_get_offsets;
s->get_resolution = vga_get_resolution;
s->hw_ops = &vga_ops;
switch (vga_retrace_method) {
case VGA_RETRACE_DUMB:
s->retrace = vga_dumb_retrace;
s->update_retrace_info = vga_dumb_update_retrace_info;
break;
case VGA_RETRACE_PRECISE:
s->retrace = vga_precise_retrace;
s->update_retrace_info = vga_precise_update_retrace_info;
break;
}
/*
* Set default fb endian based on target, could probably be turned
* into a device attribute set by the machine/platform to remove
* all target endian dependencies from this file.
*/
#ifdef TARGET_WORDS_BIGENDIAN
s->default_endian_fb = true;
#else
s->default_endian_fb = false;
#endif
vga_dirty_log_start(s);
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,395
|
static int vga_common_post_load(void *opaque, int version_id)
{
VGACommonState *s = opaque;
/* force refresh */
s->graphic_mode = -1;
vbe_update_vgaregs(s);
return 0;
}
|
DoS
| 0
|
static int vga_common_post_load(void *opaque, int version_id)
{
VGACommonState *s = opaque;
/* force refresh */
s->graphic_mode = -1;
vbe_update_vgaregs(s);
return 0;
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,396
|
void vga_common_reset(VGACommonState *s)
{
s->sr_index = 0;
memset(s->sr, '\0', sizeof(s->sr));
memset(s->sr_vbe, '\0', sizeof(s->sr_vbe));
s->gr_index = 0;
memset(s->gr, '\0', sizeof(s->gr));
s->ar_index = 0;
memset(s->ar, '\0', sizeof(s->ar));
s->ar_flip_flop = 0;
s->cr_index = 0;
memset(s->cr, '\0', sizeof(s->cr));
s->msr = 0;
s->fcr = 0;
s->st00 = 0;
s->st01 = 0;
s->dac_state = 0;
s->dac_sub_index = 0;
s->dac_read_index = 0;
s->dac_write_index = 0;
memset(s->dac_cache, '\0', sizeof(s->dac_cache));
s->dac_8bit = 0;
memset(s->palette, '\0', sizeof(s->palette));
s->bank_offset = 0;
s->vbe_index = 0;
memset(s->vbe_regs, '\0', sizeof(s->vbe_regs));
s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID5;
s->vbe_start_addr = 0;
s->vbe_line_offset = 0;
s->vbe_bank_mask = (s->vram_size >> 16) - 1;
memset(s->font_offsets, '\0', sizeof(s->font_offsets));
s->graphic_mode = -1; /* force full update */
s->shift_control = 0;
s->double_scan = 0;
s->line_offset = 0;
s->line_compare = 0;
s->start_addr = 0;
s->plane_updated = 0;
s->last_cw = 0;
s->last_ch = 0;
s->last_width = 0;
s->last_height = 0;
s->last_scr_width = 0;
s->last_scr_height = 0;
s->cursor_start = 0;
s->cursor_end = 0;
s->cursor_offset = 0;
s->big_endian_fb = s->default_endian_fb;
memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table));
memset(s->last_palette, '\0', sizeof(s->last_palette));
memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr));
switch (vga_retrace_method) {
case VGA_RETRACE_DUMB:
break;
case VGA_RETRACE_PRECISE:
memset(&s->retrace_info, 0, sizeof (s->retrace_info));
break;
}
vga_update_memory_access(s);
}
|
DoS
| 0
|
void vga_common_reset(VGACommonState *s)
{
s->sr_index = 0;
memset(s->sr, '\0', sizeof(s->sr));
memset(s->sr_vbe, '\0', sizeof(s->sr_vbe));
s->gr_index = 0;
memset(s->gr, '\0', sizeof(s->gr));
s->ar_index = 0;
memset(s->ar, '\0', sizeof(s->ar));
s->ar_flip_flop = 0;
s->cr_index = 0;
memset(s->cr, '\0', sizeof(s->cr));
s->msr = 0;
s->fcr = 0;
s->st00 = 0;
s->st01 = 0;
s->dac_state = 0;
s->dac_sub_index = 0;
s->dac_read_index = 0;
s->dac_write_index = 0;
memset(s->dac_cache, '\0', sizeof(s->dac_cache));
s->dac_8bit = 0;
memset(s->palette, '\0', sizeof(s->palette));
s->bank_offset = 0;
s->vbe_index = 0;
memset(s->vbe_regs, '\0', sizeof(s->vbe_regs));
s->vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID5;
s->vbe_start_addr = 0;
s->vbe_line_offset = 0;
s->vbe_bank_mask = (s->vram_size >> 16) - 1;
memset(s->font_offsets, '\0', sizeof(s->font_offsets));
s->graphic_mode = -1; /* force full update */
s->shift_control = 0;
s->double_scan = 0;
s->line_offset = 0;
s->line_compare = 0;
s->start_addr = 0;
s->plane_updated = 0;
s->last_cw = 0;
s->last_ch = 0;
s->last_width = 0;
s->last_height = 0;
s->last_scr_width = 0;
s->last_scr_height = 0;
s->cursor_start = 0;
s->cursor_end = 0;
s->cursor_offset = 0;
s->big_endian_fb = s->default_endian_fb;
memset(s->invalidated_y_table, '\0', sizeof(s->invalidated_y_table));
memset(s->last_palette, '\0', sizeof(s->last_palette));
memset(s->last_ch_attr, '\0', sizeof(s->last_ch_attr));
switch (vga_retrace_method) {
case VGA_RETRACE_DUMB:
break;
case VGA_RETRACE_PRECISE:
memset(&s->retrace_info, 0, sizeof (s->retrace_info));
break;
}
vga_update_memory_access(s);
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,397
|
void vga_dirty_log_start(VGACommonState *s)
{
memory_region_set_log(&s->vram, true, DIRTY_MEMORY_VGA);
}
|
DoS
| 0
|
void vga_dirty_log_start(VGACommonState *s)
{
memory_region_set_log(&s->vram, true, DIRTY_MEMORY_VGA);
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,398
|
void vga_dirty_log_stop(VGACommonState *s)
{
memory_region_set_log(&s->vram, false, DIRTY_MEMORY_VGA);
}
|
DoS
| 0
|
void vga_dirty_log_stop(VGACommonState *s)
{
memory_region_set_log(&s->vram, false, DIRTY_MEMORY_VGA);
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
2,399
|
static void vga_draw_blank(VGACommonState *s, int full_update)
{
DisplaySurface *surface = qemu_console_surface(s->con);
int i, w;
uint8_t *d;
if (!full_update)
return;
if (s->last_scr_width <= 0 || s->last_scr_height <= 0)
return;
w = s->last_scr_width * surface_bytes_per_pixel(surface);
d = surface_data(surface);
for(i = 0; i < s->last_scr_height; i++) {
memset(d, 0, w);
d += surface_stride(surface);
}
dpy_gfx_update(s->con, 0, 0,
s->last_scr_width, s->last_scr_height);
}
|
DoS
| 0
|
static void vga_draw_blank(VGACommonState *s, int full_update)
{
DisplaySurface *surface = qemu_console_surface(s->con);
int i, w;
uint8_t *d;
if (!full_update)
return;
if (s->last_scr_width <= 0 || s->last_scr_height <= 0)
return;
w = s->last_scr_width * surface_bytes_per_pixel(surface);
d = surface_data(surface);
for(i = 0; i < s->last_scr_height; i++) {
memset(d, 0, w);
d += surface_stride(surface);
}
dpy_gfx_update(s->con, 0, 0,
s->last_scr_width, s->last_scr_height);
}
|
@@ -1630,7 +1630,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)
if (!full_update) {
vga_sync_dirty_bitmap(s);
snap = memory_region_snapshot_and_clear_dirty(&s->vram, addr1,
- bwidth * height,
+ line_offset * height,
DIRTY_MEMORY_VGA);
}
|
CWE-617
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.