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,400
static void vga_draw_text(VGACommonState *s, int full_update) { DisplaySurface *surface = qemu_console_surface(s->con); int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr; int cx_min, cx_max, linesize, x_incr, line, line1; uint32_t offset, fgcol, bgcol, v, cursor_offset; uint8_t *d1, *d, *src, *dest, *cursor_ptr; const uint8_t *font_ptr, *font_base[2]; int dup9, line_offset; uint32_t *palette; uint32_t *ch_attr_ptr; int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* compute font data address (in plane 2) */ v = sr(s, VGA_SEQ_CHARACTER_MAP); offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2; if (offset != s->font_offsets[0]) { s->font_offsets[0] = offset; full_update = 1; } font_base[0] = s->vram_ptr + offset; offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2; font_base[1] = s->vram_ptr + offset; if (offset != s->font_offsets[1]) { s->font_offsets[1] = offset; full_update = 1; } if (s->plane_updated & (1 << 2) || s->has_chain4_alias) { /* if the plane 2 was modified since the last display, it indicates the font may have been modified */ s->plane_updated = 0; full_update = 1; } full_update |= update_basic_params(s); line_offset = s->line_offset; vga_get_text_resolution(s, &width, &height, &cw, &cheight); if ((height * width) <= 1) { /* better than nothing: exit if transient size is too small */ return; } if ((height * width) > CH_ATTR_SIZE) { /* better than nothing: exit if transient size is too big */ return; } if (width != s->last_width || height != s->last_height || cw != s->last_cw || cheight != s->last_ch || s->last_depth) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); surface = qemu_console_surface(s->con); dpy_text_resize(s->con, width, height); s->last_depth = 0; s->last_width = width; s->last_height = height; s->last_ch = cheight; s->last_cw = cw; full_update = 1; } full_update |= update_palette16(s); palette = s->last_palette; x_incr = cw * surface_bytes_per_pixel(surface); if (full_update) { s->full_update_text = 1; } if (s->full_update_gfx) { s->full_update_gfx = 0; full_update |= 1; } cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) | s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr; if (cursor_offset != s->cursor_offset || s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start || s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end) { /* if the cursor position changed, we update the old and new chars */ if (s->cursor_offset < CH_ATTR_SIZE) s->last_ch_attr[s->cursor_offset] = -1; if (cursor_offset < CH_ATTR_SIZE) s->last_ch_attr[cursor_offset] = -1; s->cursor_offset = cursor_offset; s->cursor_start = s->cr[VGA_CRTC_CURSOR_START]; s->cursor_end = s->cr[VGA_CRTC_CURSOR_END]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4; if (now >= s->cursor_blink_time) { s->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2; s->cursor_visible_phase = !s->cursor_visible_phase; } dest = surface_data(surface); linesize = surface_stride(surface); ch_attr_ptr = s->last_ch_attr; line = 0; offset = s->start_addr * 4; for(cy = 0; cy < height; cy++) { d1 = dest; src = s->vram_ptr + offset; cx_min = width; cx_max = -1; for(cx = 0; cx < width; cx++) { ch_attr = *(uint16_t *)src; if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) { if (cx < cx_min) cx_min = cx; if (cx > cx_max) cx_max = cx; *ch_attr_ptr = ch_attr; #ifdef HOST_WORDS_BIGENDIAN ch = ch_attr >> 8; cattr = ch_attr & 0xff; #else ch = ch_attr & 0xff; cattr = ch_attr >> 8; #endif font_ptr = font_base[(cattr >> 3) & 1]; font_ptr += 32 * 4 * ch; bgcol = palette[cattr >> 4]; fgcol = palette[cattr & 0x0f]; if (cw == 16) { vga_draw_glyph16(d1, linesize, font_ptr, cheight, fgcol, bgcol); } else if (cw != 9) { vga_draw_glyph8(d1, linesize, font_ptr, cheight, fgcol, bgcol); } else { dup9 = 0; if (ch >= 0xb0 && ch <= 0xdf && (s->ar[VGA_ATC_MODE] & 0x04)) { dup9 = 1; } vga_draw_glyph9(d1, linesize, font_ptr, cheight, fgcol, bgcol, dup9); } if (src == cursor_ptr && !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) && s->cursor_visible_phase) { int line_start, line_last, h; /* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f; line_last = s->cr[VGA_CRTC_CURSOR_END] & 0x1f; /* XXX: check that */ if (line_last > cheight - 1) line_last = cheight - 1; if (line_last >= line_start && line_start < cheight) { h = line_last - line_start + 1; d = d1 + linesize * line_start; if (cw == 16) { vga_draw_glyph16(d, linesize, cursor_glyph, h, fgcol, bgcol); } else if (cw != 9) { vga_draw_glyph8(d, linesize, cursor_glyph, h, fgcol, bgcol); } else { vga_draw_glyph9(d, linesize, cursor_glyph, h, fgcol, bgcol, 1); } } } } d1 += x_incr; src += 4; ch_attr_ptr++; } if (cx_max != -1) { dpy_gfx_update(s->con, cx_min * cw, cy * cheight, (cx_max - cx_min + 1) * cw, cheight); } dest += linesize * cheight; line1 = line + cheight; offset += line_offset; if (line < s->line_compare && line1 >= s->line_compare) { offset = 0; } line = line1; } }
DoS
0
static void vga_draw_text(VGACommonState *s, int full_update) { DisplaySurface *surface = qemu_console_surface(s->con); int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr; int cx_min, cx_max, linesize, x_incr, line, line1; uint32_t offset, fgcol, bgcol, v, cursor_offset; uint8_t *d1, *d, *src, *dest, *cursor_ptr; const uint8_t *font_ptr, *font_base[2]; int dup9, line_offset; uint32_t *palette; uint32_t *ch_attr_ptr; int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* compute font data address (in plane 2) */ v = sr(s, VGA_SEQ_CHARACTER_MAP); offset = (((v >> 4) & 1) | ((v << 1) & 6)) * 8192 * 4 + 2; if (offset != s->font_offsets[0]) { s->font_offsets[0] = offset; full_update = 1; } font_base[0] = s->vram_ptr + offset; offset = (((v >> 5) & 1) | ((v >> 1) & 6)) * 8192 * 4 + 2; font_base[1] = s->vram_ptr + offset; if (offset != s->font_offsets[1]) { s->font_offsets[1] = offset; full_update = 1; } if (s->plane_updated & (1 << 2) || s->has_chain4_alias) { /* if the plane 2 was modified since the last display, it indicates the font may have been modified */ s->plane_updated = 0; full_update = 1; } full_update |= update_basic_params(s); line_offset = s->line_offset; vga_get_text_resolution(s, &width, &height, &cw, &cheight); if ((height * width) <= 1) { /* better than nothing: exit if transient size is too small */ return; } if ((height * width) > CH_ATTR_SIZE) { /* better than nothing: exit if transient size is too big */ return; } if (width != s->last_width || height != s->last_height || cw != s->last_cw || cheight != s->last_ch || s->last_depth) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); surface = qemu_console_surface(s->con); dpy_text_resize(s->con, width, height); s->last_depth = 0; s->last_width = width; s->last_height = height; s->last_ch = cheight; s->last_cw = cw; full_update = 1; } full_update |= update_palette16(s); palette = s->last_palette; x_incr = cw * surface_bytes_per_pixel(surface); if (full_update) { s->full_update_text = 1; } if (s->full_update_gfx) { s->full_update_gfx = 0; full_update |= 1; } cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) | s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr; if (cursor_offset != s->cursor_offset || s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start || s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end) { /* if the cursor position changed, we update the old and new chars */ if (s->cursor_offset < CH_ATTR_SIZE) s->last_ch_attr[s->cursor_offset] = -1; if (cursor_offset < CH_ATTR_SIZE) s->last_ch_attr[cursor_offset] = -1; s->cursor_offset = cursor_offset; s->cursor_start = s->cr[VGA_CRTC_CURSOR_START]; s->cursor_end = s->cr[VGA_CRTC_CURSOR_END]; } cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4; if (now >= s->cursor_blink_time) { s->cursor_blink_time = now + VGA_TEXT_CURSOR_PERIOD_MS / 2; s->cursor_visible_phase = !s->cursor_visible_phase; } dest = surface_data(surface); linesize = surface_stride(surface); ch_attr_ptr = s->last_ch_attr; line = 0; offset = s->start_addr * 4; for(cy = 0; cy < height; cy++) { d1 = dest; src = s->vram_ptr + offset; cx_min = width; cx_max = -1; for(cx = 0; cx < width; cx++) { ch_attr = *(uint16_t *)src; if (full_update || ch_attr != *ch_attr_ptr || src == cursor_ptr) { if (cx < cx_min) cx_min = cx; if (cx > cx_max) cx_max = cx; *ch_attr_ptr = ch_attr; #ifdef HOST_WORDS_BIGENDIAN ch = ch_attr >> 8; cattr = ch_attr & 0xff; #else ch = ch_attr & 0xff; cattr = ch_attr >> 8; #endif font_ptr = font_base[(cattr >> 3) & 1]; font_ptr += 32 * 4 * ch; bgcol = palette[cattr >> 4]; fgcol = palette[cattr & 0x0f]; if (cw == 16) { vga_draw_glyph16(d1, linesize, font_ptr, cheight, fgcol, bgcol); } else if (cw != 9) { vga_draw_glyph8(d1, linesize, font_ptr, cheight, fgcol, bgcol); } else { dup9 = 0; if (ch >= 0xb0 && ch <= 0xdf && (s->ar[VGA_ATC_MODE] & 0x04)) { dup9 = 1; } vga_draw_glyph9(d1, linesize, font_ptr, cheight, fgcol, bgcol, dup9); } if (src == cursor_ptr && !(s->cr[VGA_CRTC_CURSOR_START] & 0x20) && s->cursor_visible_phase) { int line_start, line_last, h; /* draw the cursor */ line_start = s->cr[VGA_CRTC_CURSOR_START] & 0x1f; line_last = s->cr[VGA_CRTC_CURSOR_END] & 0x1f; /* XXX: check that */ if (line_last > cheight - 1) line_last = cheight - 1; if (line_last >= line_start && line_start < cheight) { h = line_last - line_start + 1; d = d1 + linesize * line_start; if (cw == 16) { vga_draw_glyph16(d, linesize, cursor_glyph, h, fgcol, bgcol); } else if (cw != 9) { vga_draw_glyph8(d, linesize, cursor_glyph, h, fgcol, bgcol); } else { vga_draw_glyph9(d, linesize, cursor_glyph, h, fgcol, bgcol, 1); } } } } d1 += x_incr; src += 4; ch_attr_ptr++; } if (cx_max != -1) { dpy_gfx_update(s->con, cx_min * cw, cy * cheight, (cx_max - cx_min + 1) * cw, cheight); } dest += linesize * cheight; line1 = line + cheight; offset += line_offset; if (line < s->line_compare && line1 >= s->line_compare) { offset = 0; } line = line1; } }
@@ -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,401
static uint8_t vga_dumb_retrace(VGACommonState *s) { return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE); }
DoS
0
static uint8_t vga_dumb_retrace(VGACommonState *s) { return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE); }
@@ -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,402
static void vga_dumb_update_retrace_info(VGACommonState *s) { (void) s; }
DoS
0
static void vga_dumb_update_retrace_info(VGACommonState *s) { (void) 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,403
static bool vga_endian_state_needed(void *opaque) { VGACommonState *s = opaque; /* * Only send the endian state if it's different from the * default one, thus ensuring backward compatibility for * migration of the common case */ return s->default_endian_fb != s->big_endian_fb; }
DoS
0
static bool vga_endian_state_needed(void *opaque) { VGACommonState *s = opaque; /* * Only send the endian state if it's different from the * default one, thus ensuring backward compatibility for * migration of the common case */ return s->default_endian_fb != s->big_endian_fb; }
@@ -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,404
static void vga_get_offsets(VGACommonState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare) { uint32_t start_addr, line_offset, line_compare; if (vbe_enabled(s)) { line_offset = s->vbe_line_offset; start_addr = s->vbe_start_addr; line_compare = 65535; } else { /* compute line_offset in bytes */ line_offset = s->cr[VGA_CRTC_OFFSET]; line_offset <<= 3; /* starting address */ start_addr = s->cr[VGA_CRTC_START_LO] | (s->cr[VGA_CRTC_START_HI] << 8); /* line compare */ line_compare = s->cr[VGA_CRTC_LINE_COMPARE] | ((s->cr[VGA_CRTC_OVERFLOW] & 0x10) << 4) | ((s->cr[VGA_CRTC_MAX_SCAN] & 0x40) << 3); } *pline_offset = line_offset; *pstart_addr = start_addr; *pline_compare = line_compare; }
DoS
0
static void vga_get_offsets(VGACommonState *s, uint32_t *pline_offset, uint32_t *pstart_addr, uint32_t *pline_compare) { uint32_t start_addr, line_offset, line_compare; if (vbe_enabled(s)) { line_offset = s->vbe_line_offset; start_addr = s->vbe_start_addr; line_compare = 65535; } else { /* compute line_offset in bytes */ line_offset = s->cr[VGA_CRTC_OFFSET]; line_offset <<= 3; /* starting address */ start_addr = s->cr[VGA_CRTC_START_LO] | (s->cr[VGA_CRTC_START_HI] << 8); /* line compare */ line_compare = s->cr[VGA_CRTC_LINE_COMPARE] | ((s->cr[VGA_CRTC_OVERFLOW] & 0x10) << 4) | ((s->cr[VGA_CRTC_MAX_SCAN] & 0x40) << 3); } *pline_offset = line_offset; *pstart_addr = start_addr; *pline_compare = line_compare; }
@@ -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,405
static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight) { int width, height; if (vbe_enabled(s)) { width = s->vbe_regs[VBE_DISPI_INDEX_XRES]; height = s->vbe_regs[VBE_DISPI_INDEX_YRES]; } else { width = (s->cr[VGA_CRTC_H_DISP] + 1) * 8; height = s->cr[VGA_CRTC_V_DISP_END] | ((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) | ((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3); height = (height + 1); } *pwidth = width; *pheight = height; }
DoS
0
static void vga_get_resolution(VGACommonState *s, int *pwidth, int *pheight) { int width, height; if (vbe_enabled(s)) { width = s->vbe_regs[VBE_DISPI_INDEX_XRES]; height = s->vbe_regs[VBE_DISPI_INDEX_YRES]; } else { width = (s->cr[VGA_CRTC_H_DISP] + 1) * 8; height = s->cr[VGA_CRTC_V_DISP_END] | ((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) | ((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3); height = (height + 1); } *pwidth = width; *pheight = 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
2,406
void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space, MemoryRegion *address_space_io, bool init_vga_ports) { MemoryRegion *vga_io_memory; const MemoryRegionPortio *vga_ports, *vbe_ports; qemu_register_reset(vga_reset, s); s->bank_offset = 0; s->legacy_address_space = address_space; vga_io_memory = vga_init_io(s, obj, &vga_ports, &vbe_ports); memory_region_add_subregion_overlap(address_space, 0x000a0000, vga_io_memory, 1); memory_region_set_coalescing(vga_io_memory); if (init_vga_ports) { portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga"); portio_list_set_flush_coalesced(&s->vga_port_list); portio_list_add(&s->vga_port_list, address_space_io, 0x3b0); } if (vbe_ports) { portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe"); portio_list_add(&s->vbe_port_list, address_space_io, 0x1ce); } }
DoS
0
void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space, MemoryRegion *address_space_io, bool init_vga_ports) { MemoryRegion *vga_io_memory; const MemoryRegionPortio *vga_ports, *vbe_ports; qemu_register_reset(vga_reset, s); s->bank_offset = 0; s->legacy_address_space = address_space; vga_io_memory = vga_init_io(s, obj, &vga_ports, &vbe_ports); memory_region_add_subregion_overlap(address_space, 0x000a0000, vga_io_memory, 1); memory_region_set_coalescing(vga_io_memory); if (init_vga_ports) { portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga"); portio_list_set_flush_coalesced(&s->vga_port_list); portio_list_add(&s->vga_port_list, address_space_io, 0x3b0); } if (vbe_ports) { portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe"); portio_list_add(&s->vbe_port_list, address_space_io, 0x1ce); } }
@@ -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,407
MemoryRegion *vga_init_io(VGACommonState *s, Object *obj, const MemoryRegionPortio **vga_ports, const MemoryRegionPortio **vbe_ports) { MemoryRegion *vga_mem; *vga_ports = vga_portio_list; *vbe_ports = vbe_portio_list; vga_mem = g_malloc(sizeof(*vga_mem)); memory_region_init_io(vga_mem, obj, &vga_mem_ops, s, "vga-lowmem", 0x20000); memory_region_set_flush_coalesced(vga_mem); return vga_mem; }
DoS
0
MemoryRegion *vga_init_io(VGACommonState *s, Object *obj, const MemoryRegionPortio **vga_ports, const MemoryRegionPortio **vbe_ports) { MemoryRegion *vga_mem; *vga_ports = vga_portio_list; *vbe_ports = vbe_portio_list; vga_mem = g_malloc(sizeof(*vga_mem)); memory_region_init_io(vga_mem, obj, &vga_mem_ops, s, "vga-lowmem", 0x20000); memory_region_set_flush_coalesced(vga_mem); return vga_mem; }
@@ -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,408
void vga_init_vbe(VGACommonState *s, Object *obj, MemoryRegion *system_memory) { /* With pc-0.12 and below we map both the PCI BAR and the fixed VBE region, * so use an alias to avoid double-mapping the same region. */ memory_region_init_alias(&s->vram_vbe, obj, "vram.vbe", &s->vram, 0, memory_region_size(&s->vram)); /* XXX: use optimized standard vga accesses */ memory_region_add_subregion(system_memory, VBE_DISPI_LFB_PHYSICAL_ADDRESS, &s->vram_vbe); s->vbe_mapped = 1; }
DoS
0
void vga_init_vbe(VGACommonState *s, Object *obj, MemoryRegion *system_memory) { /* With pc-0.12 and below we map both the PCI BAR and the fixed VBE region, * so use an alias to avoid double-mapping the same region. */ memory_region_init_alias(&s->vram_vbe, obj, "vram.vbe", &s->vram, 0, memory_region_size(&s->vram)); /* XXX: use optimized standard vga accesses */ memory_region_add_subregion(system_memory, VBE_DISPI_LFB_PHYSICAL_ADDRESS, &s->vram_vbe); s->vbe_mapped = 1; }
@@ -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,409
static void vga_invalidate_display(void *opaque) { VGACommonState *s = opaque; s->last_width = -1; s->last_height = -1; }
DoS
0
static void vga_invalidate_display(void *opaque) { VGACommonState *s = opaque; s->last_width = -1; s->last_height = -1; }
@@ -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,410
void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2) { int y; if (y1 >= VGA_MAX_HEIGHT) return; if (y2 >= VGA_MAX_HEIGHT) y2 = VGA_MAX_HEIGHT; for(y = y1; y < y2; y++) { s->invalidated_y_table[y >> 5] |= 1 << (y & 0x1f); } }
DoS
0
void vga_invalidate_scanlines(VGACommonState *s, int y1, int y2) { int y; if (y1 >= VGA_MAX_HEIGHT) return; if (y2 >= VGA_MAX_HEIGHT) y2 = VGA_MAX_HEIGHT; for(y = y1; y < y2; y++) { s->invalidated_y_table[y >> 5] |= 1 << (y & 0x1f); } }
@@ -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,411
int vga_ioport_invalid(VGACommonState *s, uint32_t addr) { if (s->msr & VGA_MIS_COLOR) { /* Color */ return (addr >= 0x3b0 && addr <= 0x3bf); } else { /* Monochrome */ return (addr >= 0x3d0 && addr <= 0x3df); } }
DoS
0
int vga_ioport_invalid(VGACommonState *s, uint32_t addr) { if (s->msr & VGA_MIS_COLOR) { /* Color */ return (addr >= 0x3b0 && addr <= 0x3bf); } else { /* Monochrome */ return (addr >= 0x3d0 && addr <= 0x3df); } }
@@ -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,412
uint32_t vga_ioport_read(void *opaque, uint32_t addr) { VGACommonState *s = opaque; int val, index; if (vga_ioport_invalid(s, addr)) { val = 0xff; } else { switch(addr) { case VGA_ATT_W: if (s->ar_flip_flop == 0) { val = s->ar_index; } else { val = 0; } break; case VGA_ATT_R: index = s->ar_index & 0x1f; if (index < VGA_ATT_C) { val = s->ar[index]; } else { val = 0; } break; case VGA_MIS_W: val = s->st00; break; case VGA_SEQ_I: val = s->sr_index; break; case VGA_SEQ_D: val = s->sr[s->sr_index]; #ifdef DEBUG_VGA_REG printf("vga: read SR%x = 0x%02x\n", s->sr_index, val); #endif break; case VGA_PEL_IR: val = s->dac_state; break; case VGA_PEL_IW: val = s->dac_write_index; break; case VGA_PEL_D: val = s->palette[s->dac_read_index * 3 + s->dac_sub_index]; if (++s->dac_sub_index == 3) { s->dac_sub_index = 0; s->dac_read_index++; } break; case VGA_FTC_R: val = s->fcr; break; case VGA_MIS_R: val = s->msr; break; case VGA_GFX_I: val = s->gr_index; break; case VGA_GFX_D: val = s->gr[s->gr_index]; #ifdef DEBUG_VGA_REG printf("vga: read GR%x = 0x%02x\n", s->gr_index, val); #endif break; case VGA_CRT_IM: case VGA_CRT_IC: val = s->cr_index; break; case VGA_CRT_DM: case VGA_CRT_DC: val = s->cr[s->cr_index]; #ifdef DEBUG_VGA_REG printf("vga: read CR%x = 0x%02x\n", s->cr_index, val); #endif break; case VGA_IS1_RM: case VGA_IS1_RC: /* just toggle to fool polling */ val = s->st01 = s->retrace(s); s->ar_flip_flop = 0; break; default: val = 0x00; break; } } trace_vga_std_read_io(addr, val); return val; }
DoS
0
uint32_t vga_ioport_read(void *opaque, uint32_t addr) { VGACommonState *s = opaque; int val, index; if (vga_ioport_invalid(s, addr)) { val = 0xff; } else { switch(addr) { case VGA_ATT_W: if (s->ar_flip_flop == 0) { val = s->ar_index; } else { val = 0; } break; case VGA_ATT_R: index = s->ar_index & 0x1f; if (index < VGA_ATT_C) { val = s->ar[index]; } else { val = 0; } break; case VGA_MIS_W: val = s->st00; break; case VGA_SEQ_I: val = s->sr_index; break; case VGA_SEQ_D: val = s->sr[s->sr_index]; #ifdef DEBUG_VGA_REG printf("vga: read SR%x = 0x%02x\n", s->sr_index, val); #endif break; case VGA_PEL_IR: val = s->dac_state; break; case VGA_PEL_IW: val = s->dac_write_index; break; case VGA_PEL_D: val = s->palette[s->dac_read_index * 3 + s->dac_sub_index]; if (++s->dac_sub_index == 3) { s->dac_sub_index = 0; s->dac_read_index++; } break; case VGA_FTC_R: val = s->fcr; break; case VGA_MIS_R: val = s->msr; break; case VGA_GFX_I: val = s->gr_index; break; case VGA_GFX_D: val = s->gr[s->gr_index]; #ifdef DEBUG_VGA_REG printf("vga: read GR%x = 0x%02x\n", s->gr_index, val); #endif break; case VGA_CRT_IM: case VGA_CRT_IC: val = s->cr_index; break; case VGA_CRT_DM: case VGA_CRT_DC: val = s->cr[s->cr_index]; #ifdef DEBUG_VGA_REG printf("vga: read CR%x = 0x%02x\n", s->cr_index, val); #endif break; case VGA_IS1_RM: case VGA_IS1_RC: /* just toggle to fool polling */ val = s->st01 = s->retrace(s); s->ar_flip_flop = 0; break; default: val = 0x00; break; } } trace_vga_std_read_io(addr, 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,413
static uint64_t vga_mem_read(void *opaque, hwaddr addr, unsigned size) { VGACommonState *s = opaque; return vga_mem_readb(s, addr); }
DoS
0
static uint64_t vga_mem_read(void *opaque, hwaddr addr, unsigned size) { VGACommonState *s = opaque; return vga_mem_readb(s, addr); }
@@ -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,414
uint32_t vga_mem_readb(VGACommonState *s, hwaddr addr) { int memory_map_mode, plane; uint32_t ret; /* convert to VGA memory offset */ memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3; addr &= 0x1ffff; switch(memory_map_mode) { case 0: break; case 1: if (addr >= 0x10000) return 0xff; addr += s->bank_offset; break; case 2: addr -= 0x10000; if (addr >= 0x8000) return 0xff; break; default: case 3: addr -= 0x18000; if (addr >= 0x8000) return 0xff; break; } if (sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) { /* chain 4 mode : simplest access */ assert(addr < s->vram_size); ret = s->vram_ptr[addr]; } else if (s->gr[VGA_GFX_MODE] & 0x10) { /* odd/even mode (aka text mode mapping) */ plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1); addr = ((addr & ~1) << 1) | plane; if (addr >= s->vram_size) { return 0xff; } ret = s->vram_ptr[addr]; } else { /* standard VGA latched access */ if (addr * sizeof(uint32_t) >= s->vram_size) { return 0xff; } s->latch = ((uint32_t *)s->vram_ptr)[addr]; if (!(s->gr[VGA_GFX_MODE] & 0x08)) { /* read mode 0 */ plane = s->gr[VGA_GFX_PLANE_READ]; ret = GET_PLANE(s->latch, plane); } else { /* read mode 1 */ ret = (s->latch ^ mask16[s->gr[VGA_GFX_COMPARE_VALUE]]) & mask16[s->gr[VGA_GFX_COMPARE_MASK]]; ret |= ret >> 16; ret |= ret >> 8; ret = (~ret) & 0xff; } } return ret; }
DoS
0
uint32_t vga_mem_readb(VGACommonState *s, hwaddr addr) { int memory_map_mode, plane; uint32_t ret; /* convert to VGA memory offset */ memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3; addr &= 0x1ffff; switch(memory_map_mode) { case 0: break; case 1: if (addr >= 0x10000) return 0xff; addr += s->bank_offset; break; case 2: addr -= 0x10000; if (addr >= 0x8000) return 0xff; break; default: case 3: addr -= 0x18000; if (addr >= 0x8000) return 0xff; break; } if (sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) { /* chain 4 mode : simplest access */ assert(addr < s->vram_size); ret = s->vram_ptr[addr]; } else if (s->gr[VGA_GFX_MODE] & 0x10) { /* odd/even mode (aka text mode mapping) */ plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1); addr = ((addr & ~1) << 1) | plane; if (addr >= s->vram_size) { return 0xff; } ret = s->vram_ptr[addr]; } else { /* standard VGA latched access */ if (addr * sizeof(uint32_t) >= s->vram_size) { return 0xff; } s->latch = ((uint32_t *)s->vram_ptr)[addr]; if (!(s->gr[VGA_GFX_MODE] & 0x08)) { /* read mode 0 */ plane = s->gr[VGA_GFX_PLANE_READ]; ret = GET_PLANE(s->latch, plane); } else { /* read mode 1 */ ret = (s->latch ^ mask16[s->gr[VGA_GFX_COMPARE_VALUE]]) & mask16[s->gr[VGA_GFX_COMPARE_MASK]]; ret |= ret >> 16; ret |= ret >> 8; ret = (~ret) & 0xff; } } return ret; }
@@ -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,415
static void vga_mem_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { VGACommonState *s = opaque; vga_mem_writeb(s, addr, data); }
DoS
0
static void vga_mem_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { VGACommonState *s = opaque; vga_mem_writeb(s, addr, data); }
@@ -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,416
void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val) { int memory_map_mode, plane, write_mode, b, func_select, mask; uint32_t write_mask, bit_mask, set_mask; #ifdef DEBUG_VGA_MEM printf("vga: [0x" TARGET_FMT_plx "] = 0x%02x\n", addr, val); #endif /* convert to VGA memory offset */ memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3; addr &= 0x1ffff; switch(memory_map_mode) { case 0: break; case 1: if (addr >= 0x10000) return; addr += s->bank_offset; break; case 2: addr -= 0x10000; if (addr >= 0x8000) return; break; default: case 3: addr -= 0x18000; if (addr >= 0x8000) return; break; } if (sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) { /* chain 4 mode : simplest access */ plane = addr & 3; mask = (1 << plane); if (sr(s, VGA_SEQ_PLANE_WRITE) & mask) { assert(addr < s->vram_size); s->vram_ptr[addr] = val; #ifdef DEBUG_VGA_MEM printf("vga: chain4: [0x" TARGET_FMT_plx "]\n", addr); #endif s->plane_updated |= mask; /* only used to detect font change */ memory_region_set_dirty(&s->vram, addr, 1); } } else if (s->gr[VGA_GFX_MODE] & 0x10) { /* odd/even mode (aka text mode mapping) */ plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1); mask = (1 << plane); if (sr(s, VGA_SEQ_PLANE_WRITE) & mask) { addr = ((addr & ~1) << 1) | plane; if (addr >= s->vram_size) { return; } s->vram_ptr[addr] = val; #ifdef DEBUG_VGA_MEM printf("vga: odd/even: [0x" TARGET_FMT_plx "]\n", addr); #endif s->plane_updated |= mask; /* only used to detect font change */ memory_region_set_dirty(&s->vram, addr, 1); } } else { /* standard VGA latched access */ write_mode = s->gr[VGA_GFX_MODE] & 3; switch(write_mode) { default: case 0: /* rotate */ b = s->gr[VGA_GFX_DATA_ROTATE] & 7; val = ((val >> b) | (val << (8 - b))) & 0xff; val |= val << 8; val |= val << 16; /* apply set/reset mask */ set_mask = mask16[s->gr[VGA_GFX_SR_ENABLE]]; val = (val & ~set_mask) | (mask16[s->gr[VGA_GFX_SR_VALUE]] & set_mask); bit_mask = s->gr[VGA_GFX_BIT_MASK]; break; case 1: val = s->latch; goto do_write; case 2: val = mask16[val & 0x0f]; bit_mask = s->gr[VGA_GFX_BIT_MASK]; break; case 3: /* rotate */ b = s->gr[VGA_GFX_DATA_ROTATE] & 7; val = (val >> b) | (val << (8 - b)); bit_mask = s->gr[VGA_GFX_BIT_MASK] & val; val = mask16[s->gr[VGA_GFX_SR_VALUE]]; break; } /* apply logical operation */ func_select = s->gr[VGA_GFX_DATA_ROTATE] >> 3; switch(func_select) { case 0: default: /* nothing to do */ break; case 1: /* and */ val &= s->latch; break; case 2: /* or */ val |= s->latch; break; case 3: /* xor */ val ^= s->latch; break; } /* apply bit mask */ bit_mask |= bit_mask << 8; bit_mask |= bit_mask << 16; val = (val & bit_mask) | (s->latch & ~bit_mask); do_write: /* mask data according to sr[2] */ mask = sr(s, VGA_SEQ_PLANE_WRITE); s->plane_updated |= mask; /* only used to detect font change */ write_mask = mask16[mask]; if (addr * sizeof(uint32_t) >= s->vram_size) { return; } ((uint32_t *)s->vram_ptr)[addr] = (((uint32_t *)s->vram_ptr)[addr] & ~write_mask) | (val & write_mask); #ifdef DEBUG_VGA_MEM printf("vga: latch: [0x" TARGET_FMT_plx "] mask=0x%08x val=0x%08x\n", addr * 4, write_mask, val); #endif memory_region_set_dirty(&s->vram, addr << 2, sizeof(uint32_t)); } }
DoS
0
void vga_mem_writeb(VGACommonState *s, hwaddr addr, uint32_t val) { int memory_map_mode, plane, write_mode, b, func_select, mask; uint32_t write_mask, bit_mask, set_mask; #ifdef DEBUG_VGA_MEM printf("vga: [0x" TARGET_FMT_plx "] = 0x%02x\n", addr, val); #endif /* convert to VGA memory offset */ memory_map_mode = (s->gr[VGA_GFX_MISC] >> 2) & 3; addr &= 0x1ffff; switch(memory_map_mode) { case 0: break; case 1: if (addr >= 0x10000) return; addr += s->bank_offset; break; case 2: addr -= 0x10000; if (addr >= 0x8000) return; break; default: case 3: addr -= 0x18000; if (addr >= 0x8000) return; break; } if (sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) { /* chain 4 mode : simplest access */ plane = addr & 3; mask = (1 << plane); if (sr(s, VGA_SEQ_PLANE_WRITE) & mask) { assert(addr < s->vram_size); s->vram_ptr[addr] = val; #ifdef DEBUG_VGA_MEM printf("vga: chain4: [0x" TARGET_FMT_plx "]\n", addr); #endif s->plane_updated |= mask; /* only used to detect font change */ memory_region_set_dirty(&s->vram, addr, 1); } } else if (s->gr[VGA_GFX_MODE] & 0x10) { /* odd/even mode (aka text mode mapping) */ plane = (s->gr[VGA_GFX_PLANE_READ] & 2) | (addr & 1); mask = (1 << plane); if (sr(s, VGA_SEQ_PLANE_WRITE) & mask) { addr = ((addr & ~1) << 1) | plane; if (addr >= s->vram_size) { return; } s->vram_ptr[addr] = val; #ifdef DEBUG_VGA_MEM printf("vga: odd/even: [0x" TARGET_FMT_plx "]\n", addr); #endif s->plane_updated |= mask; /* only used to detect font change */ memory_region_set_dirty(&s->vram, addr, 1); } } else { /* standard VGA latched access */ write_mode = s->gr[VGA_GFX_MODE] & 3; switch(write_mode) { default: case 0: /* rotate */ b = s->gr[VGA_GFX_DATA_ROTATE] & 7; val = ((val >> b) | (val << (8 - b))) & 0xff; val |= val << 8; val |= val << 16; /* apply set/reset mask */ set_mask = mask16[s->gr[VGA_GFX_SR_ENABLE]]; val = (val & ~set_mask) | (mask16[s->gr[VGA_GFX_SR_VALUE]] & set_mask); bit_mask = s->gr[VGA_GFX_BIT_MASK]; break; case 1: val = s->latch; goto do_write; case 2: val = mask16[val & 0x0f]; bit_mask = s->gr[VGA_GFX_BIT_MASK]; break; case 3: /* rotate */ b = s->gr[VGA_GFX_DATA_ROTATE] & 7; val = (val >> b) | (val << (8 - b)); bit_mask = s->gr[VGA_GFX_BIT_MASK] & val; val = mask16[s->gr[VGA_GFX_SR_VALUE]]; break; } /* apply logical operation */ func_select = s->gr[VGA_GFX_DATA_ROTATE] >> 3; switch(func_select) { case 0: default: /* nothing to do */ break; case 1: /* and */ val &= s->latch; break; case 2: /* or */ val |= s->latch; break; case 3: /* xor */ val ^= s->latch; break; } /* apply bit mask */ bit_mask |= bit_mask << 8; bit_mask |= bit_mask << 16; val = (val & bit_mask) | (s->latch & ~bit_mask); do_write: /* mask data according to sr[2] */ mask = sr(s, VGA_SEQ_PLANE_WRITE); s->plane_updated |= mask; /* only used to detect font change */ write_mask = mask16[mask]; if (addr * sizeof(uint32_t) >= s->vram_size) { return; } ((uint32_t *)s->vram_ptr)[addr] = (((uint32_t *)s->vram_ptr)[addr] & ~write_mask) | (val & write_mask); #ifdef DEBUG_VGA_MEM printf("vga: latch: [0x" TARGET_FMT_plx "] mask=0x%08x val=0x%08x\n", addr * 4, write_mask, val); #endif memory_region_set_dirty(&s->vram, addr << 2, sizeof(uint32_t)); } }
@@ -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,417
static uint8_t vga_precise_retrace(VGACommonState *s) { struct vga_precise_retrace *r = &s->retrace_info.precise; uint8_t val = s->st01 & ~(ST01_V_RETRACE | ST01_DISP_ENABLE); if (r->total_chars) { int cur_line, cur_line_char, cur_char; int64_t cur_tick; cur_tick = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); cur_char = (cur_tick / r->ticks_per_char) % r->total_chars; cur_line = cur_char / r->htotal; if (cur_line >= r->vstart && cur_line <= r->vend) { val |= ST01_V_RETRACE | ST01_DISP_ENABLE; } else { cur_line_char = cur_char % r->htotal; if (cur_line_char >= r->hstart && cur_line_char <= r->hend) { val |= ST01_DISP_ENABLE; } } return val; } else { return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE); } }
DoS
0
static uint8_t vga_precise_retrace(VGACommonState *s) { struct vga_precise_retrace *r = &s->retrace_info.precise; uint8_t val = s->st01 & ~(ST01_V_RETRACE | ST01_DISP_ENABLE); if (r->total_chars) { int cur_line, cur_line_char, cur_char; int64_t cur_tick; cur_tick = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); cur_char = (cur_tick / r->ticks_per_char) % r->total_chars; cur_line = cur_char / r->htotal; if (cur_line >= r->vstart && cur_line <= r->vend) { val |= ST01_V_RETRACE | ST01_DISP_ENABLE; } else { cur_line_char = cur_char % r->htotal; if (cur_line_char >= r->hstart && cur_line_char <= r->hend) { val |= ST01_DISP_ENABLE; } } return val; } else { return s->st01 ^ (ST01_V_RETRACE | ST01_DISP_ENABLE); } }
@@ -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,418
static void vga_precise_update_retrace_info(VGACommonState *s) { int htotal_chars; int hretr_start_char; int hretr_skew_chars; int hretr_end_char; int vtotal_lines; int vretr_start_line; int vretr_end_line; int dots; #if 0 int div2, sldiv2; #endif int clocking_mode; int clock_sel; const int clk_hz[] = {25175000, 28322000, 25175000, 25175000}; int64_t chars_per_sec; struct vga_precise_retrace *r = &s->retrace_info.precise; htotal_chars = s->cr[VGA_CRTC_H_TOTAL] + 5; hretr_start_char = s->cr[VGA_CRTC_H_SYNC_START]; hretr_skew_chars = (s->cr[VGA_CRTC_H_SYNC_END] >> 5) & 3; hretr_end_char = s->cr[VGA_CRTC_H_SYNC_END] & 0x1f; vtotal_lines = (s->cr[VGA_CRTC_V_TOTAL] | (((s->cr[VGA_CRTC_OVERFLOW] & 1) | ((s->cr[VGA_CRTC_OVERFLOW] >> 4) & 2)) << 8)) + 2; vretr_start_line = s->cr[VGA_CRTC_V_SYNC_START] | ((((s->cr[VGA_CRTC_OVERFLOW] >> 2) & 1) | ((s->cr[VGA_CRTC_OVERFLOW] >> 6) & 2)) << 8); vretr_end_line = s->cr[VGA_CRTC_V_SYNC_END] & 0xf; clocking_mode = (sr(s, VGA_SEQ_CLOCK_MODE) >> 3) & 1; clock_sel = (s->msr >> 2) & 3; dots = (s->msr & 1) ? 8 : 9; chars_per_sec = clk_hz[clock_sel] / dots; htotal_chars <<= clocking_mode; r->total_chars = vtotal_lines * htotal_chars; if (r->freq) { r->ticks_per_char = NANOSECONDS_PER_SECOND / (r->total_chars * r->freq); } else { r->ticks_per_char = NANOSECONDS_PER_SECOND / chars_per_sec; } r->vstart = vretr_start_line; r->vend = r->vstart + vretr_end_line + 1; r->hstart = hretr_start_char + hretr_skew_chars; r->hend = r->hstart + hretr_end_char + 1; r->htotal = htotal_chars; #if 0 div2 = (s->cr[VGA_CRTC_MODE] >> 2) & 1; sldiv2 = (s->cr[VGA_CRTC_MODE] >> 3) & 1; printf ( "hz=%f\n" "htotal = %d\n" "hretr_start = %d\n" "hretr_skew = %d\n" "hretr_end = %d\n" "vtotal = %d\n" "vretr_start = %d\n" "vretr_end = %d\n" "div2 = %d sldiv2 = %d\n" "clocking_mode = %d\n" "clock_sel = %d %d\n" "dots = %d\n" "ticks/char = %" PRId64 "\n" "\n", (double) NANOSECONDS_PER_SECOND / (r->ticks_per_char * r->total_chars), htotal_chars, hretr_start_char, hretr_skew_chars, hretr_end_char, vtotal_lines, vretr_start_line, vretr_end_line, div2, sldiv2, clocking_mode, clock_sel, clk_hz[clock_sel], dots, r->ticks_per_char ); #endif }
DoS
0
static void vga_precise_update_retrace_info(VGACommonState *s) { int htotal_chars; int hretr_start_char; int hretr_skew_chars; int hretr_end_char; int vtotal_lines; int vretr_start_line; int vretr_end_line; int dots; #if 0 int div2, sldiv2; #endif int clocking_mode; int clock_sel; const int clk_hz[] = {25175000, 28322000, 25175000, 25175000}; int64_t chars_per_sec; struct vga_precise_retrace *r = &s->retrace_info.precise; htotal_chars = s->cr[VGA_CRTC_H_TOTAL] + 5; hretr_start_char = s->cr[VGA_CRTC_H_SYNC_START]; hretr_skew_chars = (s->cr[VGA_CRTC_H_SYNC_END] >> 5) & 3; hretr_end_char = s->cr[VGA_CRTC_H_SYNC_END] & 0x1f; vtotal_lines = (s->cr[VGA_CRTC_V_TOTAL] | (((s->cr[VGA_CRTC_OVERFLOW] & 1) | ((s->cr[VGA_CRTC_OVERFLOW] >> 4) & 2)) << 8)) + 2; vretr_start_line = s->cr[VGA_CRTC_V_SYNC_START] | ((((s->cr[VGA_CRTC_OVERFLOW] >> 2) & 1) | ((s->cr[VGA_CRTC_OVERFLOW] >> 6) & 2)) << 8); vretr_end_line = s->cr[VGA_CRTC_V_SYNC_END] & 0xf; clocking_mode = (sr(s, VGA_SEQ_CLOCK_MODE) >> 3) & 1; clock_sel = (s->msr >> 2) & 3; dots = (s->msr & 1) ? 8 : 9; chars_per_sec = clk_hz[clock_sel] / dots; htotal_chars <<= clocking_mode; r->total_chars = vtotal_lines * htotal_chars; if (r->freq) { r->ticks_per_char = NANOSECONDS_PER_SECOND / (r->total_chars * r->freq); } else { r->ticks_per_char = NANOSECONDS_PER_SECOND / chars_per_sec; } r->vstart = vretr_start_line; r->vend = r->vstart + vretr_end_line + 1; r->hstart = hretr_start_char + hretr_skew_chars; r->hend = r->hstart + hretr_end_char + 1; r->htotal = htotal_chars; #if 0 div2 = (s->cr[VGA_CRTC_MODE] >> 2) & 1; sldiv2 = (s->cr[VGA_CRTC_MODE] >> 3) & 1; printf ( "hz=%f\n" "htotal = %d\n" "hretr_start = %d\n" "hretr_skew = %d\n" "hretr_end = %d\n" "vtotal = %d\n" "vretr_start = %d\n" "vretr_end = %d\n" "div2 = %d sldiv2 = %d\n" "clocking_mode = %d\n" "clock_sel = %d %d\n" "dots = %d\n" "ticks/char = %" PRId64 "\n" "\n", (double) NANOSECONDS_PER_SECOND / (r->ticks_per_char * r->total_chars), htotal_chars, hretr_start_char, hretr_skew_chars, hretr_end_char, vtotal_lines, vretr_start_line, vretr_end_line, div2, sldiv2, clocking_mode, clock_sel, clk_hz[clock_sel], dots, r->ticks_per_char ); #endif }
@@ -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,419
static void vga_reset(void *opaque) { VGACommonState *s = opaque; vga_common_reset(s); }
DoS
0
static void vga_reset(void *opaque) { VGACommonState *s = opaque; vga_common_reset(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,420
static void vga_update_display(void *opaque) { VGACommonState *s = opaque; DisplaySurface *surface = qemu_console_surface(s->con); int full_update, graphic_mode; qemu_flush_coalesced_mmio_buffer(); if (surface_bits_per_pixel(surface) == 0) { /* nothing to do */ } else { full_update = 0; if (!(s->ar_index & 0x20)) { graphic_mode = GMODE_BLANK; } else { graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE; } if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; s->cursor_blink_time = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); full_update = 1; } switch(graphic_mode) { case GMODE_TEXT: vga_draw_text(s, full_update); break; case GMODE_GRAPH: vga_draw_graphic(s, full_update); break; case GMODE_BLANK: default: vga_draw_blank(s, full_update); break; } } }
DoS
0
static void vga_update_display(void *opaque) { VGACommonState *s = opaque; DisplaySurface *surface = qemu_console_surface(s->con); int full_update, graphic_mode; qemu_flush_coalesced_mmio_buffer(); if (surface_bits_per_pixel(surface) == 0) { /* nothing to do */ } else { full_update = 0; if (!(s->ar_index & 0x20)) { graphic_mode = GMODE_BLANK; } else { graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE; } if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; s->cursor_blink_time = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); full_update = 1; } switch(graphic_mode) { case GMODE_TEXT: vga_draw_text(s, full_update); break; case GMODE_GRAPH: vga_draw_graphic(s, full_update); break; case GMODE_BLANK: default: vga_draw_blank(s, full_update); break; } } }
@@ -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,421
static void vga_update_memory_access(VGACommonState *s) { hwaddr base, offset, size; if (s->legacy_address_space == NULL) { return; } if (s->has_chain4_alias) { memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias); object_unparent(OBJECT(&s->chain4_alias)); s->has_chain4_alias = false; s->plane_updated = 0xf; } if ((sr(s, VGA_SEQ_PLANE_WRITE) & VGA_SR02_ALL_PLANES) == VGA_SR02_ALL_PLANES && sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) { offset = 0; switch ((s->gr[VGA_GFX_MISC] >> 2) & 3) { case 0: base = 0xa0000; size = 0x20000; break; case 1: base = 0xa0000; size = 0x10000; offset = s->bank_offset; break; case 2: base = 0xb0000; size = 0x8000; break; case 3: default: base = 0xb8000; size = 0x8000; break; } assert(offset + size <= s->vram_size); memory_region_init_alias(&s->chain4_alias, memory_region_owner(&s->vram), "vga.chain4", &s->vram, offset, size); memory_region_add_subregion_overlap(s->legacy_address_space, base, &s->chain4_alias, 2); s->has_chain4_alias = true; } }
DoS
0
static void vga_update_memory_access(VGACommonState *s) { hwaddr base, offset, size; if (s->legacy_address_space == NULL) { return; } if (s->has_chain4_alias) { memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias); object_unparent(OBJECT(&s->chain4_alias)); s->has_chain4_alias = false; s->plane_updated = 0xf; } if ((sr(s, VGA_SEQ_PLANE_WRITE) & VGA_SR02_ALL_PLANES) == VGA_SR02_ALL_PLANES && sr(s, VGA_SEQ_MEMORY_MODE) & VGA_SR04_CHN_4M) { offset = 0; switch ((s->gr[VGA_GFX_MISC] >> 2) & 3) { case 0: base = 0xa0000; size = 0x20000; break; case 1: base = 0xa0000; size = 0x10000; offset = s->bank_offset; break; case 2: base = 0xb0000; size = 0x8000; break; case 3: default: base = 0xb8000; size = 0x8000; break; } assert(offset + size <= s->vram_size); memory_region_init_alias(&s->chain4_alias, memory_region_owner(&s->vram), "vga.chain4", &s->vram, offset, size); memory_region_add_subregion_overlap(s->legacy_address_space, base, &s->chain4_alias, 2); s->has_chain4_alias = true; } }
@@ -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,422
static void vga_update_text(void *opaque, console_ch_t *chardata) { VGACommonState *s = opaque; int graphic_mode, i, cursor_offset, cursor_visible; int cw, cheight, width, height, size, c_min, c_max; uint32_t *src; console_ch_t *dst, val; char msg_buffer[80]; int full_update = 0; qemu_flush_coalesced_mmio_buffer(); if (!(s->ar_index & 0x20)) { graphic_mode = GMODE_BLANK; } else { graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE; } if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; full_update = 1; } if (s->last_width == -1) { s->last_width = 0; full_update = 1; } switch (graphic_mode) { case GMODE_TEXT: /* TODO: update palette */ full_update |= update_basic_params(s); /* total width & height */ cheight = (s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1; cw = 8; if (!(sr(s, VGA_SEQ_CLOCK_MODE) & VGA_SR01_CHAR_CLK_8DOTS)) { cw = 9; } if (sr(s, VGA_SEQ_CLOCK_MODE) & 0x08) { cw = 16; /* NOTE: no 18 pixel wide */ } width = (s->cr[VGA_CRTC_H_DISP] + 1); if (s->cr[VGA_CRTC_V_TOTAL] == 100) { /* ugly hack for CGA 160x100x16 - explain me the logic */ height = 100; } else { height = s->cr[VGA_CRTC_V_DISP_END] | ((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) | ((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3); height = (height + 1) / cheight; } size = (height * width); if (size > CH_ATTR_SIZE) { if (!full_update) return; snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Text mode", width, height); break; } if (width != s->last_width || height != s->last_height || cw != s->last_cw || cheight != s->last_ch) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); dpy_text_resize(s->con, width, height); s->last_depth = 0; s->last_width = width; s->last_height = height; s->last_ch = cheight; s->last_cw = cw; full_update = 1; } if (full_update) { s->full_update_gfx = 1; } if (s->full_update_text) { s->full_update_text = 0; full_update |= 1; } /* Update "hardware" cursor */ cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) | s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr; if (cursor_offset != s->cursor_offset || s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start || s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) { cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START] & 0x20); if (cursor_visible && cursor_offset < size && cursor_offset >= 0) dpy_text_cursor(s->con, TEXTMODE_X(cursor_offset), TEXTMODE_Y(cursor_offset)); else dpy_text_cursor(s->con, -1, -1); s->cursor_offset = cursor_offset; s->cursor_start = s->cr[VGA_CRTC_CURSOR_START]; s->cursor_end = s->cr[VGA_CRTC_CURSOR_END]; } src = (uint32_t *) s->vram_ptr + s->start_addr; dst = chardata; if (full_update) { for (i = 0; i < size; src ++, dst ++, i ++) console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src))); dpy_text_update(s->con, 0, 0, width, height); } else { c_max = 0; for (i = 0; i < size; src ++, dst ++, i ++) { console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); if (*dst != val) { *dst = val; c_max = i; break; } } c_min = i; for (; i < size; src ++, dst ++, i ++) { console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); if (*dst != val) { *dst = val; c_max = i; } } if (c_min <= c_max) { i = TEXTMODE_Y(c_min); dpy_text_update(s->con, 0, i, width, TEXTMODE_Y(c_max) - i + 1); } } return; case GMODE_GRAPH: if (!full_update) return; s->get_resolution(s, &width, &height); snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Graphic mode", width, height); break; case GMODE_BLANK: default: if (!full_update) return; snprintf(msg_buffer, sizeof(msg_buffer), "VGA Blank mode"); break; } /* Display a message */ s->last_width = 60; s->last_height = height = 3; dpy_text_cursor(s->con, -1, -1); dpy_text_resize(s->con, s->last_width, height); for (dst = chardata, i = 0; i < s->last_width * height; i ++) console_write_ch(dst ++, ' '); size = strlen(msg_buffer); width = (s->last_width - size) / 2; dst = chardata + s->last_width + width; for (i = 0; i < size; i ++) console_write_ch(dst ++, ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE, QEMU_COLOR_BLACK, 1)); dpy_text_update(s->con, 0, 0, s->last_width, height); }
DoS
0
static void vga_update_text(void *opaque, console_ch_t *chardata) { VGACommonState *s = opaque; int graphic_mode, i, cursor_offset, cursor_visible; int cw, cheight, width, height, size, c_min, c_max; uint32_t *src; console_ch_t *dst, val; char msg_buffer[80]; int full_update = 0; qemu_flush_coalesced_mmio_buffer(); if (!(s->ar_index & 0x20)) { graphic_mode = GMODE_BLANK; } else { graphic_mode = s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_MODE; } if (graphic_mode != s->graphic_mode) { s->graphic_mode = graphic_mode; full_update = 1; } if (s->last_width == -1) { s->last_width = 0; full_update = 1; } switch (graphic_mode) { case GMODE_TEXT: /* TODO: update palette */ full_update |= update_basic_params(s); /* total width & height */ cheight = (s->cr[VGA_CRTC_MAX_SCAN] & 0x1f) + 1; cw = 8; if (!(sr(s, VGA_SEQ_CLOCK_MODE) & VGA_SR01_CHAR_CLK_8DOTS)) { cw = 9; } if (sr(s, VGA_SEQ_CLOCK_MODE) & 0x08) { cw = 16; /* NOTE: no 18 pixel wide */ } width = (s->cr[VGA_CRTC_H_DISP] + 1); if (s->cr[VGA_CRTC_V_TOTAL] == 100) { /* ugly hack for CGA 160x100x16 - explain me the logic */ height = 100; } else { height = s->cr[VGA_CRTC_V_DISP_END] | ((s->cr[VGA_CRTC_OVERFLOW] & 0x02) << 7) | ((s->cr[VGA_CRTC_OVERFLOW] & 0x40) << 3); height = (height + 1) / cheight; } size = (height * width); if (size > CH_ATTR_SIZE) { if (!full_update) return; snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Text mode", width, height); break; } if (width != s->last_width || height != s->last_height || cw != s->last_cw || cheight != s->last_ch) { s->last_scr_width = width * cw; s->last_scr_height = height * cheight; qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); dpy_text_resize(s->con, width, height); s->last_depth = 0; s->last_width = width; s->last_height = height; s->last_ch = cheight; s->last_cw = cw; full_update = 1; } if (full_update) { s->full_update_gfx = 1; } if (s->full_update_text) { s->full_update_text = 0; full_update |= 1; } /* Update "hardware" cursor */ cursor_offset = ((s->cr[VGA_CRTC_CURSOR_HI] << 8) | s->cr[VGA_CRTC_CURSOR_LO]) - s->start_addr; if (cursor_offset != s->cursor_offset || s->cr[VGA_CRTC_CURSOR_START] != s->cursor_start || s->cr[VGA_CRTC_CURSOR_END] != s->cursor_end || full_update) { cursor_visible = !(s->cr[VGA_CRTC_CURSOR_START] & 0x20); if (cursor_visible && cursor_offset < size && cursor_offset >= 0) dpy_text_cursor(s->con, TEXTMODE_X(cursor_offset), TEXTMODE_Y(cursor_offset)); else dpy_text_cursor(s->con, -1, -1); s->cursor_offset = cursor_offset; s->cursor_start = s->cr[VGA_CRTC_CURSOR_START]; s->cursor_end = s->cr[VGA_CRTC_CURSOR_END]; } src = (uint32_t *) s->vram_ptr + s->start_addr; dst = chardata; if (full_update) { for (i = 0; i < size; src ++, dst ++, i ++) console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src))); dpy_text_update(s->con, 0, 0, width, height); } else { c_max = 0; for (i = 0; i < size; src ++, dst ++, i ++) { console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); if (*dst != val) { *dst = val; c_max = i; break; } } c_min = i; for (; i < size; src ++, dst ++, i ++) { console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); if (*dst != val) { *dst = val; c_max = i; } } if (c_min <= c_max) { i = TEXTMODE_Y(c_min); dpy_text_update(s->con, 0, i, width, TEXTMODE_Y(c_max) - i + 1); } } return; case GMODE_GRAPH: if (!full_update) return; s->get_resolution(s, &width, &height); snprintf(msg_buffer, sizeof(msg_buffer), "%i x %i Graphic mode", width, height); break; case GMODE_BLANK: default: if (!full_update) return; snprintf(msg_buffer, sizeof(msg_buffer), "VGA Blank mode"); break; } /* Display a message */ s->last_width = 60; s->last_height = height = 3; dpy_text_cursor(s->con, -1, -1); dpy_text_resize(s->con, s->last_width, height); for (dst = chardata, i = 0; i < s->last_width * height; i ++) console_write_ch(dst ++, ' '); size = strlen(msg_buffer); width = (s->last_width - size) / 2; dst = chardata + s->last_width + width; for (i = 0; i < size; i ++) console_write_ch(dst ++, ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE, QEMU_COLOR_BLACK, 1)); dpy_text_update(s->con, 0, 0, s->last_width, 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
2,423
static int checkBlackPoint(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[3]; ref *tempref; code = dict_find_string(CIEdict, "BlackPoint", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 3) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 3, value); if (code < 0) return code; } return 0; }
null
0
static int checkBlackPoint(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[3]; ref *tempref; code = dict_find_string(CIEdict, "BlackPoint", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 3) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 3, value); if (code < 0) return code; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,424
static int checkCalMatrix(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[9]; ref *tempref; code = dict_find_string(CIEdict, "Matrix", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 9) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 9, value); if (code < 0) return code; } return 0; }
null
0
static int checkCalMatrix(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[9]; ref *tempref; code = dict_find_string(CIEdict, "Matrix", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 9) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 9, value); if (code < 0) return code; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,425
static int checkDecodeLMN(i_ctx_t * i_ctx_p, ref *CIEdict) { int code = 0, i; ref *tempref, valref; code = dict_find_string(CIEdict, "DecodeLMN", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 3) return_error(gs_error_rangecheck); for (i=0;i<3;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; check_proc(valref); } } return 0; }
null
0
static int checkDecodeLMN(i_ctx_t * i_ctx_p, ref *CIEdict) { int code = 0, i; ref *tempref, valref; code = dict_find_string(CIEdict, "DecodeLMN", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 3) return_error(gs_error_rangecheck); for (i=0;i<3;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; check_proc(valref); } } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,426
static int checkGamma(i_ctx_t * i_ctx_p, ref *CIEdict, int numvalues) { int code = 0, i; float value[3]; ref *tempref, valref; code = dict_find_string(CIEdict, "Gamma", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (numvalues > 1) { /* Array of gammas (RGB) */ if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != numvalues) return_error(gs_error_rangecheck); for (i=0;i<numvalues;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) value[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) value[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); if (value[i] <= 0) return_error(gs_error_rangecheck); } } else { /* Single gamma (gray) */ if (r_has_type(tempref, t_real)) value[0] = (float)(tempref->value.realval); else if (r_has_type(tempref, t_integer)) value[0] = (float)(tempref->value.intval); else return_error(gs_error_typecheck); if (value[0] <= 0) return_error(gs_error_rangecheck); } } return 0; }
null
0
static int checkGamma(i_ctx_t * i_ctx_p, ref *CIEdict, int numvalues) { int code = 0, i; float value[3]; ref *tempref, valref; code = dict_find_string(CIEdict, "Gamma", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (numvalues > 1) { /* Array of gammas (RGB) */ if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != numvalues) return_error(gs_error_rangecheck); for (i=0;i<numvalues;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) value[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) value[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); if (value[i] <= 0) return_error(gs_error_rangecheck); } } else { /* Single gamma (gray) */ if (r_has_type(tempref, t_real)) value[0] = (float)(tempref->value.realval); else if (r_has_type(tempref, t_integer)) value[0] = (float)(tempref->value.intval); else return_error(gs_error_typecheck); if (value[0] <= 0) return_error(gs_error_rangecheck); } } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,427
static int checkMatrixLMN(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[9]; ref *tempref; code = dict_find_string(CIEdict, "MatrixLMN", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 9) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 9, value); if (code < 0) return code; } return 0; }
null
0
static int checkMatrixLMN(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[9]; ref *tempref; code = dict_find_string(CIEdict, "MatrixLMN", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 9) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 9, value); if (code < 0) return code; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,428
static int checkWhitePoint(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[3]; ref *tempref; code = dict_find_string(CIEdict, "WhitePoint", &tempref); if (code < 0) return code; if (code == 0 || r_has_type(tempref, t_null)) return gs_note_error(gs_error_undefined); if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 3) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 3, value); if (code < 0) return code; /* Xw and Zw must be positive and Yw must be 1 (3rd edition PLRM p230) */ if (value[0] < 0 || value[1] != 1 || value[2] < 0 ) return_error(gs_error_rangecheck); return 0; }
null
0
static int checkWhitePoint(i_ctx_t * i_ctx_p, ref *CIEdict) { int code; float value[3]; ref *tempref; code = dict_find_string(CIEdict, "WhitePoint", &tempref); if (code < 0) return code; if (code == 0 || r_has_type(tempref, t_null)) return gs_note_error(gs_error_undefined); if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 3) return_error(gs_error_rangecheck); code = get_cie_param_array(imemory, tempref, 3, value); if (code < 0) return code; /* Xw and Zw must be positive and Yw must be 1 (3rd edition PLRM p230) */ if (value[0] < 0 || value[1] != 1 || value[2] < 0 ) return_error(gs_error_rangecheck); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,429
static int checkrangeab(i_ctx_t * i_ctx_p, ref *labdict) { int code = 0, i; float value[4]; ref *tempref, valref; code = dict_find_string(labdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 4) return_error(gs_error_rangecheck); for (i=0;i<4;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) value[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) value[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); } if (value[1] < value[0] || value[3] < value[2] ) return_error(gs_error_rangecheck); } return 0; }
null
0
static int checkrangeab(i_ctx_t * i_ctx_p, ref *labdict) { int code = 0, i; float value[4]; ref *tempref, valref; code = dict_find_string(labdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { if (!r_is_array(tempref)) return_error(gs_error_typecheck); if (r_size(tempref) != 4) return_error(gs_error_rangecheck); for (i=0;i<4;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) value[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) value[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); } if (value[1] < value[0] || value[3] < value[2] ) return_error(gs_error_rangecheck); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,430
static int cieabccompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { int code = 0; ref CIEdict1, CIEdict2; code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &CIEdict2); if (code < 0) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN")) return 0; return 1; }
null
0
static int cieabccompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { int code = 0; ref CIEdict1, CIEdict2; code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &CIEdict2); if (code < 0) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN")) return 0; return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,431
static int cieabcdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeABC, get the values from that */ code = dict_find_string(&CIEdict, "RangeABC", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 6, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedABC */ memcpy(ptr, default_0_1, 6*sizeof(float)); } return 0; }
null
0
static int cieabcdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeABC, get the values from that */ code = dict_find_string(&CIEdict, "RangeABC", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 6, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedABC */ memcpy(ptr, default_0_1, 6*sizeof(float)); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,432
static int cieabcrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeABC, get the values from that */ code = dict_find_string(&CIEdict, "RangeABC", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 6, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedABC */ memcpy(ptr, default_0_1, 6*sizeof(float)); } return 0; }
null
0
static int cieabcrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeABC, get the values from that */ code = dict_find_string(&CIEdict, "RangeABC", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 6, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedABC */ memcpy(ptr, default_0_1, 6*sizeof(float)); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,433
static int cieabcvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 3) return_error(gs_error_stackunderflow); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } return 0; }
null
0
static int cieabcvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 3) return_error(gs_error_stackunderflow); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,434
static int cieacompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { int code = 0; ref CIEdict1, CIEdict2; code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &CIEdict2); if (code < 0) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeA")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeA")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixA")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN")) return 0; return 1; }
null
0
static int cieacompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { int code = 0; ref CIEdict1, CIEdict2; code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &CIEdict2); if (code < 0) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeA")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeA")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixA")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN")) return 0; return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,435
static int cieadomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeA entry in the dictionary, get the * values from that */ code = dict_find_string(&CIEdict, "RangeA", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 2, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedA */ ptr[0] = 0; ptr[1] = 1; } return 0; }
null
0
static int cieadomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeA entry in the dictionary, get the * values from that */ code = dict_find_string(&CIEdict, "RangeA", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 2, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedA */ ptr[0] = 0; ptr[1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,436
static int ciearange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeA entry in the dictionary, get the * values from that */ code = dict_find_string(&CIEdict, "RangeA", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 2, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedA */ ptr[0] = 0; ptr[1] = 1; } return 0; }
null
0
static int ciearange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeA entry in the dictionary, get the * values from that */ code = dict_find_string(&CIEdict, "RangeA", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 2, ptr); if (code < 0) return code; } else { /* Default values for CIEBasedA */ ptr[0] = 0; ptr[1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,437
static int cieavalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; if (num_comps < 1) return_error(gs_error_stackunderflow); if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); return 0; }
null
0
static int cieavalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; if (num_comps < 1) return_error(gs_error_stackunderflow); if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,438
static int ciebasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op; ref *spacename, nref; int i, components=1, code; /* If the spaece is an array, the first element is always the name */ if (r_is_array(space)) spacename = space->value.refs; else spacename = space; /* Check that it really is a name */ if (!r_has_type(spacename, t_name)) return_error(gs_error_typecheck); /* Find the relevant color space object */ for (i=0;i<4;i++) { code = names_ref(imemory->gs_lib_ctx->gs_name_table, (const byte *)CIESpaces[i], strlen(CIESpaces[i]), &nref, 0); if (code < 0) return code; if (name_eq(spacename, &nref)) { break; } } /* Find out how many values are on the stack, which depends * on what kind of CIEBased space this is. */ switch(i){ case 0: components = 1; break; case 1: case 2: components = 3; break; case 3: components = 4; break; } /* Remove teh requisite number of values */ pop(components); op = osp; /* Find out how many values we need to return, which * depends on the requested space. */ switch(base) { case 0: components = 1; break; case 1: case 2: components = 3; break; case 3: components = 4; break; } push(components); /* The PLRM says that all the components should be returned as 0.0 */ op -= components-1; for (i=0;i<components;i++) { make_real(op, (float)0); op++; } /* However, Adobe implementations actually return 1.0 for the black * channel of CMYK... */ if (components == 4) { op--; make_real(op, (float)1); } *stage = 0; *cont = 0; return 0; }
null
0
static int ciebasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op; ref *spacename, nref; int i, components=1, code; /* If the spaece is an array, the first element is always the name */ if (r_is_array(space)) spacename = space->value.refs; else spacename = space; /* Check that it really is a name */ if (!r_has_type(spacename, t_name)) return_error(gs_error_typecheck); /* Find the relevant color space object */ for (i=0;i<4;i++) { code = names_ref(imemory->gs_lib_ctx->gs_name_table, (const byte *)CIESpaces[i], strlen(CIESpaces[i]), &nref, 0); if (code < 0) return code; if (name_eq(spacename, &nref)) { break; } } /* Find out how many values are on the stack, which depends * on what kind of CIEBased space this is. */ switch(i){ case 0: components = 1; break; case 1: case 2: components = 3; break; case 3: components = 4; break; } /* Remove teh requisite number of values */ pop(components); op = osp; /* Find out how many values we need to return, which * depends on the requested space. */ switch(base) { case 0: components = 1; break; case 1: case 2: components = 3; break; case 3: components = 4; break; } push(components); /* The PLRM says that all the components should be returned as 0.0 */ op -= components-1; for (i=0;i<components;i++) { make_real(op, (float)0); op++; } /* However, Adobe implementations actually return 1.0 for the black * channel of CMYK... */ if (components == 4) { op--; make_real(op, (float)1); } *stage = 0; *cont = 0; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,439
static int ciedefcompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { int code = 0; ref CIEdict1, CIEdict2; code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &CIEdict2); if (code < 0) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeDEF")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeDEF")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeHIJ")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"Table")) return 0; return 1; }
null
0
static int ciedefcompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { int code = 0; ref CIEdict1, CIEdict2; code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &CIEdict2); if (code < 0) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"WhitePoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"BlackPoint")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixABC")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeLMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"MatrixMN")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeDEF")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"DecodeDEF")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"RangeHIJ")) return 0; if (!comparedictkey(i_ctx_p, &CIEdict1, &CIEdict2, (char *)"Table")) return 0; return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,440
static int ciedefdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeDEF, get the values from that */ code = dict_find_string(&CIEdict, "RangeDEF", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 6, ptr); if (code < 0) return code; } else { /* Default values for a CIEBasedDEF */ memcpy(ptr, default_0_1, 6*sizeof(float)); } return 0; }
null
0
static int ciedefdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeDEF, get the values from that */ code = dict_find_string(&CIEdict, "RangeDEF", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 6, ptr); if (code < 0) return code; } else { /* Default values for a CIEBasedDEF */ memcpy(ptr, default_0_1, 6*sizeof(float)); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,441
static int ciedefgdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeDEFG, get the values from that */ code = dict_find_string(&CIEdict, "RangeDEFG", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 8, ptr); if (code < 0) return code; } else { /* Default values for a CIEBasedDEFG */ memcpy(ptr, default_0_1, 8*sizeof(float)); } return 0; }
null
0
static int ciedefgdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeDEFG, get the values from that */ code = dict_find_string(&CIEdict, "RangeDEFG", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 8, ptr); if (code < 0) return code; } else { /* Default values for a CIEBasedDEFG */ memcpy(ptr, default_0_1, 8*sizeof(float)); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,442
static int ciedefgrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeDEFG, get the values from that */ code = dict_find_string(&CIEdict, "RangeDEFG", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 8, ptr); if (code < 0) return code; } else { /* Default values for a CIEBasedDEFG */ memcpy(ptr, default_0_1, 8*sizeof(float)); } return 0; }
null
0
static int ciedefgrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref CIEdict, *tempref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a RangeDEFG, get the values from that */ code = dict_find_string(&CIEdict, "RangeDEFG", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { code = get_cie_param_array(imemory, tempref, 8, ptr); if (code < 0) return code; } else { /* Default values for a CIEBasedDEFG */ memcpy(ptr, default_0_1, 8*sizeof(float)); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,443
static int ciedefvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 3) return_error(gs_error_stackunderflow); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } return 0; }
null
0
static int ciedefvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 3) return_error(gs_error_stackunderflow); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,444
static int cmykinitialproc(i_ctx_t *i_ctx_p, ref *space) { gs_client_color cc; cc.pattern = 0x00; cc.paint.values[0] = 0; cc.paint.values[1] = 0; cc.paint.values[2] = 0; cc.paint.values[3] = 1; return gs_setcolor(igs, &cc); }
null
0
static int cmykinitialproc(i_ctx_t *i_ctx_p, ref *space) { gs_client_color cc; cc.pattern = 0x00; cc.paint.values[0] = 0; cc.paint.values[1] = 0; cc.paint.values[2] = 0; cc.paint.values[3] = 1; return gs_setcolor(igs, &cc); }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,445
static int cmykrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i; for (i = 0;i < 8;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
null
0
static int cmykrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i; for (i = 0;i < 8;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,446
static int cmykvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 4) return_error(gs_error_stackunderflow); op -= 3; for (i=0;i < 4;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } for (i=0;i < 4; i++) { if (values[i] > 1.0) values[i] = 1.0; if (values[i] < 0.0) values[i] = 0.0; } return 0; }
null
0
static int cmykvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 4) return_error(gs_error_stackunderflow); op -= 3; for (i=0;i < 4;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } for (i=0;i < 4; i++) { if (values[i] > 1.0) values[i] = 1.0; if (values[i] < 0.0) values[i] = 0.0; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,447
static int comparearrays(i_ctx_t * i_ctx_p, ref *m1, ref *m2) { int i, code; ref ref1, ref2; if (r_size(m1) != r_size(m2)) return 0; for (i=0;i < r_size(m1);i++) { code = array_get(imemory, m1, i, &ref1); if (code < 0) return 0; code = array_get(imemory, m2, i, &ref2); if (code < 0) return 0; if (r_type(&ref1) != r_type(&ref2)) return 0; code = r_type(&ref1); if (code < 0) return code; switch(r_type(&ref1)) { case t_null: break; case t_boolean: if (ref1.value.boolval != ref2.value.boolval) return 0; break; case t_integer: if (ref1.value.intval != ref2.value.intval) return 0; break; case t_real: if (ref1.value.realval != ref2.value.realval) return 0; break; case t_name: if (!name_eq(&ref1, &ref2)) return 0; break; case t_string: if (r_size(&ref1) != r_size(&ref2)) return 0; if (strncmp((const char *)ref1.value.const_bytes, (const char *)ref2.value.const_bytes, r_size(&ref1)) != 0) return 0; break; case t_array: case t_mixedarray: case t_shortarray: if (!comparearrays(i_ctx_p, &ref1, &ref2)) return 0; break; case t_oparray: break; case t_operator: if (ref1.value.opproc != ref2.value.opproc) return 0; break; case t__invalid: case t_dictionary: case t_file: case t_unused_array_: case t_struct: case t_astruct: case t_fontID: case t_save: case t_mark: case t_device: return 0; default: /* Some high frequency operators are defined starting at t_next_index * I think as long as the 'type' of each is the same, we are OK */ break; } } return 1; }
null
0
static int comparearrays(i_ctx_t * i_ctx_p, ref *m1, ref *m2) { int i, code; ref ref1, ref2; if (r_size(m1) != r_size(m2)) return 0; for (i=0;i < r_size(m1);i++) { code = array_get(imemory, m1, i, &ref1); if (code < 0) return 0; code = array_get(imemory, m2, i, &ref2); if (code < 0) return 0; if (r_type(&ref1) != r_type(&ref2)) return 0; code = r_type(&ref1); if (code < 0) return code; switch(r_type(&ref1)) { case t_null: break; case t_boolean: if (ref1.value.boolval != ref2.value.boolval) return 0; break; case t_integer: if (ref1.value.intval != ref2.value.intval) return 0; break; case t_real: if (ref1.value.realval != ref2.value.realval) return 0; break; case t_name: if (!name_eq(&ref1, &ref2)) return 0; break; case t_string: if (r_size(&ref1) != r_size(&ref2)) return 0; if (strncmp((const char *)ref1.value.const_bytes, (const char *)ref2.value.const_bytes, r_size(&ref1)) != 0) return 0; break; case t_array: case t_mixedarray: case t_shortarray: if (!comparearrays(i_ctx_p, &ref1, &ref2)) return 0; break; case t_oparray: break; case t_operator: if (ref1.value.opproc != ref2.value.opproc) return 0; break; case t__invalid: case t_dictionary: case t_file: case t_unused_array_: case t_struct: case t_astruct: case t_fontID: case t_save: case t_mark: case t_device: return 0; default: /* Some high frequency operators are defined starting at t_next_index * I think as long as the 'type' of each is the same, we are OK */ break; } } return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,448
static int devicenalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst) { ref altspace; int code; code = array_get(imemory, space, 2, &altspace); if (code < 0) return code; ref_assign(*r, &altspace); return 0; }
null
0
static int devicenalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst) { ref altspace; int code; code = array_get(imemory, space, 2, &altspace); if (code < 0) return code; ref_assign(*r, &altspace); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,449
static int devicenbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; /* required by "push" macro */ int code, use, n_comp; ref narray; code = devicentransform(i_ctx_p, space, &use, stage, stack_depth); if (code != 0) return code; if (!use) { *stage = 0; *cont = 0; code = array_get(imemory, space, 1, &narray); if (code < 0) return code; n_comp = r_size(&narray); pop(n_comp); op = osp; switch(base) { case 0: push(1); make_real(op, 0.0); break; case 1: case 2: push(3); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; case 3: push(4); make_real(&op[-3], 0.0); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; } } else { *stage = 0; *cont = 1; } return 0; }
null
0
static int devicenbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; /* required by "push" macro */ int code, use, n_comp; ref narray; code = devicentransform(i_ctx_p, space, &use, stage, stack_depth); if (code != 0) return code; if (!use) { *stage = 0; *cont = 0; code = array_get(imemory, space, 1, &narray); if (code < 0) return code; n_comp = r_size(&narray); pop(n_comp); op = osp; switch(base) { case 0: push(1); make_real(op, 0.0); break; case 1: case 2: push(3); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; case 3: push(4); make_real(&op[-3], 0.0); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; } } else { *stage = 0; *cont = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,450
static int devicencolorants_cont(i_ctx_t *i_ctx_p) { ref dict, *pdict = &dict, space[2], sname; int index, code, depth, stage; es_ptr ep = esp, pindex, pstage; os_ptr op = osp; gs_separation_name sep_name; pindex = &ep[-2]; pstage = &ep[-1]; index = (int)pindex->value.intval; stage = (int)pstage->value.intval; ref_assign(&dict, ep); do { index = dict_next(pdict, index, (ref *)&space); if (index == -1) { esp -= 4; return o_pop_estack; } if (stage == 0) { code = gs_gsave(igs); if (code < 0) return code; code = validate_spaces(i_ctx_p, &space[1], &depth); if (code < 0) { (void)gs_grestore(igs); return code; } /* If we get a continuation from a sub-procedure, we will want to come back * here afterward, to do any remaining stages. We need to set up for that now. * so that our continuation is ahead of the sub-proc's continuation. */ check_estack(1); push(1); /* The push_op_estack macro increments esp before use, so we don't need to */ push_op_estack(devicencolorants_cont); make_int(pstage, 1); *op = space[1]; code = zsetcolorspace(i_ctx_p); if (code < 0) { (void)gs_grestore(igs); return code; } else return code; } else { stage = 0; switch (r_type(&space[0])) { case t_string: code = name_from_string(imemory, &space[0], &sname); if (code < 0){ (void)gs_grestore(igs); return code; } sep_name = name_index(imemory, &sname); break; case t_name: sep_name = name_index(imemory, &space[0]); break; default: (void)gs_grestore(igs); return_error(gs_error_typecheck); break; } make_int(pindex, index); make_int(pstage, stage); gs_attachattributecolorspace(sep_name, igs); code = gs_grestore(igs); if (code < 0) return code; } } while(1); }
null
0
static int devicencolorants_cont(i_ctx_t *i_ctx_p) { ref dict, *pdict = &dict, space[2], sname; int index, code, depth, stage; es_ptr ep = esp, pindex, pstage; os_ptr op = osp; gs_separation_name sep_name; pindex = &ep[-2]; pstage = &ep[-1]; index = (int)pindex->value.intval; stage = (int)pstage->value.intval; ref_assign(&dict, ep); do { index = dict_next(pdict, index, (ref *)&space); if (index == -1) { esp -= 4; return o_pop_estack; } if (stage == 0) { code = gs_gsave(igs); if (code < 0) return code; code = validate_spaces(i_ctx_p, &space[1], &depth); if (code < 0) { (void)gs_grestore(igs); return code; } /* If we get a continuation from a sub-procedure, we will want to come back * here afterward, to do any remaining stages. We need to set up for that now. * so that our continuation is ahead of the sub-proc's continuation. */ check_estack(1); push(1); /* The push_op_estack macro increments esp before use, so we don't need to */ push_op_estack(devicencolorants_cont); make_int(pstage, 1); *op = space[1]; code = zsetcolorspace(i_ctx_p); if (code < 0) { (void)gs_grestore(igs); return code; } else return code; } else { stage = 0; switch (r_type(&space[0])) { case t_string: code = name_from_string(imemory, &space[0], &sname); if (code < 0){ (void)gs_grestore(igs); return code; } sep_name = name_index(imemory, &sname); break; case t_name: sep_name = name_index(imemory, &space[0]); break; default: (void)gs_grestore(igs); return_error(gs_error_typecheck); break; } make_int(pindex, index); make_int(pstage, stage); gs_attachattributecolorspace(sep_name, igs); code = gs_grestore(igs); if (code < 0) return code; } } while(1); }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,451
static int devicencompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { ref sname1, sname2; int code; code = array_get(imemory, space, 1, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &sname2); if (code < 0) return 0; if (!r_is_array(&sname1)) return 0; if (!r_is_array(&sname2)) return 0; if (!comparearrays(i_ctx_p, &sname1, &sname2)) return 0; code = array_get(imemory, testspace, 2, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 2, &sname2); if (code < 0) return 0; if (r_type(&sname1) != r_type(&sname2)) return 0; if (r_is_array(&sname1)) { if (!comparearrays(i_ctx_p, &sname1, &sname2)) return 0; } else { if (!r_has_type(&sname1, t_name)) return 0; if (!name_eq(&sname1, &sname2)) return 0; } code = array_get(imemory, space, 3, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 3, &sname2); if (code < 0) return 0; return(comparearrays(i_ctx_p, &sname1, &sname2)); }
null
0
static int devicencompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { ref sname1, sname2; int code; code = array_get(imemory, space, 1, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &sname2); if (code < 0) return 0; if (!r_is_array(&sname1)) return 0; if (!r_is_array(&sname2)) return 0; if (!comparearrays(i_ctx_p, &sname1, &sname2)) return 0; code = array_get(imemory, testspace, 2, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 2, &sname2); if (code < 0) return 0; if (r_type(&sname1) != r_type(&sname2)) return 0; if (r_is_array(&sname1)) { if (!comparearrays(i_ctx_p, &sname1, &sname2)) return 0; } else { if (!r_has_type(&sname1, t_name)) return 0; if (!name_eq(&sname1, &sname2)) return 0; } code = array_get(imemory, space, 3, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 3, &sname2); if (code < 0) return 0; return(comparearrays(i_ctx_p, &sname1, &sname2)); }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,452
static int devicencomponents(i_ctx_t * i_ctx_p, ref *space, int *n) { ref namesarray; int code; code = array_get(imemory, space, 1, &namesarray); if (code < 0) return code; *n = r_size(&namesarray); return 0; }
null
0
static int devicencomponents(i_ctx_t * i_ctx_p, ref *space, int *n) { ref namesarray; int code; code = array_get(imemory, space, 1, &namesarray); if (code < 0) return code; *n = r_size(&namesarray); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,453
static int devicendomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, limit, code; ref namesarray; code = array_get(imemory, space, 1, &namesarray); if (code < 0) return code; limit = r_size(&namesarray) * 2; for (i = 0;i < limit;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
null
0
static int devicendomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, limit, code; ref namesarray; code = array_get(imemory, space, 1, &namesarray); if (code < 0) return code; limit = r_size(&namesarray) * 2; for (i = 0;i < limit;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,454
static int deviceninitialproc(i_ctx_t *i_ctx_p, ref *space) { gs_client_color cc; int i, num_components, code; ref namesarray; code = array_get(imemory, space, 1, &namesarray); if (code < 0) return code; num_components = r_size(&namesarray); cc.pattern = 0x00; for (i=0;i<num_components;i++) cc.paint.values[i] = 1.0; return gs_setcolor(igs, &cc); }
null
0
static int deviceninitialproc(i_ctx_t *i_ctx_p, ref *space) { gs_client_color cc; int i, num_components, code; ref namesarray; code = array_get(imemory, space, 1, &namesarray); if (code < 0) return code; num_components = r_size(&namesarray); cc.pattern = 0x00; for (i=0;i<num_components;i++) cc.paint.values[i] = 1.0; return gs_setcolor(igs, &cc); }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,455
static int devicenrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, limit, code; PS_colour_space_t *cspace; ref altspace; code = array_get(imemory, space, 1, &altspace); if (code < 0) return code; code = get_space_object(i_ctx_p, &altspace, &cspace); if (code < 0) return code; code = cspace->numcomponents(i_ctx_p, &altspace, &limit); if (code < 0) return code; for (i = 0;i < limit * 2;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
null
0
static int devicenrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, limit, code; PS_colour_space_t *cspace; ref altspace; code = array_get(imemory, space, 1, &altspace); if (code < 0) return code; code = get_space_object(i_ctx_p, &altspace, &cspace); if (code < 0) return code; code = cspace->numcomponents(i_ctx_p, &altspace, &limit); if (code < 0) return code; for (i = 0;i < limit * 2;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,456
static int devicentransform(i_ctx_t *i_ctx_p, ref *devicenspace, int *usealternate, int *stage, int *stack_depth) { gx_device * dev = igs->device; ref narray, sname, proc; int i, code, colorant_number; *usealternate = 0; code = array_get(imemory, devicenspace, 1, &narray); if (code < 0) return code; if (!r_is_array(&narray)) return_error(gs_error_typecheck); for (i=0;i<r_size(&narray);i++) { code = array_get(imemory, &narray, i, &sname); if (code < 0) return code; if (r_has_type(&sname, t_name)) { name_string_ref(imemory, &sname, &sname); } /* Check for /All and /None, never need the alternate for these */ if (r_size(&sname) == 3 && strncmp("All", (const char *)sname.value.bytes, r_size(&sname)) == 0) continue; if (r_size(&sname) == 4 && strncmp("None", (const char *)sname.value.bytes, r_size(&sname)) == 0) continue; /* * Compare the colorant name to the device's. If the device's * compare routine returns GX_DEVICE_COLOR_MAX_COMPONENTS then the * colorant is in the SeparationNames list but not in the * SeparationOrder list. */ colorant_number = (*dev_proc(dev, get_color_comp_index)) (dev, (const char *)sname.value.bytes, r_size(&sname), SEPARATION_NAME); if (colorant_number < 0) { /* If not valid colorant name */ *usealternate = 1; break; } } if (*usealternate && *stage == 0) { (*stage)++; esp++; code = array_get(imemory, devicenspace, 3, &proc); if (code < 0) return code; *esp = proc; return o_push_estack; } if (*stage == 1){ *stack_depth = 0; *stage = 0; } return 0; }
null
0
static int devicentransform(i_ctx_t *i_ctx_p, ref *devicenspace, int *usealternate, int *stage, int *stack_depth) { gx_device * dev = igs->device; ref narray, sname, proc; int i, code, colorant_number; *usealternate = 0; code = array_get(imemory, devicenspace, 1, &narray); if (code < 0) return code; if (!r_is_array(&narray)) return_error(gs_error_typecheck); for (i=0;i<r_size(&narray);i++) { code = array_get(imemory, &narray, i, &sname); if (code < 0) return code; if (r_has_type(&sname, t_name)) { name_string_ref(imemory, &sname, &sname); } /* Check for /All and /None, never need the alternate for these */ if (r_size(&sname) == 3 && strncmp("All", (const char *)sname.value.bytes, r_size(&sname)) == 0) continue; if (r_size(&sname) == 4 && strncmp("None", (const char *)sname.value.bytes, r_size(&sname)) == 0) continue; /* * Compare the colorant name to the device's. If the device's * compare routine returns GX_DEVICE_COLOR_MAX_COMPONENTS then the * colorant is in the SeparationNames list but not in the * SeparationOrder list. */ colorant_number = (*dev_proc(dev, get_color_comp_index)) (dev, (const char *)sname.value.bytes, r_size(&sname), SEPARATION_NAME); if (colorant_number < 0) { /* If not valid colorant name */ *usealternate = 1; break; } } if (*usealternate && *stage == 0) { (*stage)++; esp++; code = array_get(imemory, devicenspace, 3, &proc); if (code < 0) return code; *esp = proc; return o_push_estack; } if (*stage == 1){ *stack_depth = 0; *stage = 0; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,457
static int devicepbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; *stage = 0; *cont = 0; make_int(op, 0); return 0; }
null
0
static int devicepbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; *stage = 0; *cont = 0; make_int(op, 0); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,458
static int devicepdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref tref; code = array_get(imemory, space, 1, &tref); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)(1 << tref.value.intval); return 0; }
null
0
static int devicepdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref tref; code = array_get(imemory, space, 1, &tref); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)(1 << tref.value.intval); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,459
static int deviceprange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref tref; code = array_get(imemory, space, 1, &tref); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)(1 << tref.value.intval); return 0; }
null
0
static int deviceprange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int code; ref tref; code = array_get(imemory, space, 1, &tref); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)(1 << tref.value.intval); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,460
static int devicepvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { return 0; }
null
0
static int devicepvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,461
static int dummydomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { return 0; }
null
0
static int dummydomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,462
static int dummyrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { return 0; }
null
0
static int dummyrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,463
static int falsecompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { return 0; }
null
0
static int falsecompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,464
static int fourcomponent(i_ctx_t * i_ctx_p, ref *space, int *n) { *n = 4; return 0; }
null
0
static int fourcomponent(i_ctx_t * i_ctx_p, ref *space, int *n) { *n = 4; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,465
static int get_cie_param_array(const gs_memory_t *mem, const ref *src, int n, float *dst) { ref valref; int i; int code = 0; for (i = 0; i < n; i++) { code = array_get(mem, src, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) dst[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) dst[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); if (dst[i] < -MAX_CIE_RANGE || dst[i] > MAX_CIE_RANGE) return_error(gs_error_limitcheck); } return code; }
null
0
static int get_cie_param_array(const gs_memory_t *mem, const ref *src, int n, float *dst) { ref valref; int i; int code = 0; for (i = 0; i < n; i++) { code = array_get(mem, src, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) dst[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) dst[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); if (dst[i] < -MAX_CIE_RANGE || dst[i] > MAX_CIE_RANGE) return_error(gs_error_limitcheck); } return code; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,466
static int graybasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; float Gray, RGB[3]; *cont = 0; *stage = 0; check_op(1); if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { Gray = op->value.realval; } else return_error(gs_error_typecheck); } else Gray = (float)op->value.intval; if (Gray < 0 || Gray > 1) return_error(gs_error_rangecheck); switch (base) { case 0: /* Requested space is DeviceGray, just use the value */ make_real(op, Gray); break; case 1: /* Requested space is HSB */ case 2: /* Requested space is RGB, set all the components * to the gray value */ push(2); RGB[0] = RGB[1] = RGB[2] = Gray; if (base == 1) /* If the requested space is HSB, convert the RGB to HSB */ rgb2hsb((float *)&RGB); make_real(&op[-2], RGB[0]); make_real(&op[-1], RGB[1]); make_real(op, RGB[2]); break; case 3: /* Requested space is CMYK, use the gray value to set the * black channel. */ push(3); make_real(&op[-3], (float)0); make_real(&op[-2], (float)0); make_real(&op[-1], (float)0); make_real(op, (float)1.0 - Gray); break; default: return_error(gs_error_undefined); } return 0; }
null
0
static int graybasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; float Gray, RGB[3]; *cont = 0; *stage = 0; check_op(1); if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { Gray = op->value.realval; } else return_error(gs_error_typecheck); } else Gray = (float)op->value.intval; if (Gray < 0 || Gray > 1) return_error(gs_error_rangecheck); switch (base) { case 0: /* Requested space is DeviceGray, just use the value */ make_real(op, Gray); break; case 1: /* Requested space is HSB */ case 2: /* Requested space is RGB, set all the components * to the gray value */ push(2); RGB[0] = RGB[1] = RGB[2] = Gray; if (base == 1) /* If the requested space is HSB, convert the RGB to HSB */ rgb2hsb((float *)&RGB); make_real(&op[-2], RGB[0]); make_real(&op[-1], RGB[1]); make_real(op, RGB[2]); break; case 3: /* Requested space is CMYK, use the gray value to set the * black channel. */ push(3); make_real(&op[-3], (float)0); make_real(&op[-2], (float)0); make_real(&op[-1], (float)0); make_real(op, (float)1.0 - Gray); break; default: return_error(gs_error_undefined); } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,467
static int graydomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
null
0
static int graydomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,468
static int grayrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
null
0
static int grayrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,469
static int grayvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); if (num_comps < 1) return_error(gs_error_stackunderflow); if (*values > 1.0) *values = 1.0; if ( *values < 0.0) *values = 0.0; return 0; }
null
0
static int grayvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); if (num_comps < 1) return_error(gs_error_stackunderflow); if (*values > 1.0) *values = 1.0; if ( *values < 0.0) *values = 0.0; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,470
static int hasharray(i_ctx_t * i_ctx_p, ref *m1, gs_md5_state_t *md5) { int i, code; ref ref1; for (i=0;i < r_size(m1);i++) { code = array_get(imemory, m1, i, &ref1); if (code < 0) return 0; code = r_type(&ref1); if (code < 0) return code; switch(r_type(&ref1)) { case t_null: break; case t_boolean: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.boolval, sizeof(ref1.value.boolval)); break; case t_integer: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.intval, sizeof(ref1.value.intval)); break; case t_real: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.realval, sizeof(ref1.value.realval)); break; case t_name: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.pname, sizeof(ref1.value.pname)); break; case t_string: gs_md5_append(md5, (const gs_md5_byte_t *)ref1.value.const_bytes, r_size(&ref1)); break; case t_array: case t_mixedarray: case t_shortarray: if (!hasharray(i_ctx_p, &ref1, md5)) return 0; break; case t_oparray: break; case t_operator: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.opproc, sizeof(ref1.value.opproc)); break; case t__invalid: case t_dictionary: case t_file: case t_unused_array_: case t_struct: case t_astruct: case t_fontID: case t_save: case t_mark: case t_device: return 0; default: /* Some high frequency operators are defined starting at t_next_index * I think as long as the 'type' of each is the same, we are OK */ break; } } return 1; }
null
0
static int hasharray(i_ctx_t * i_ctx_p, ref *m1, gs_md5_state_t *md5) { int i, code; ref ref1; for (i=0;i < r_size(m1);i++) { code = array_get(imemory, m1, i, &ref1); if (code < 0) return 0; code = r_type(&ref1); if (code < 0) return code; switch(r_type(&ref1)) { case t_null: break; case t_boolean: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.boolval, sizeof(ref1.value.boolval)); break; case t_integer: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.intval, sizeof(ref1.value.intval)); break; case t_real: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.realval, sizeof(ref1.value.realval)); break; case t_name: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.pname, sizeof(ref1.value.pname)); break; case t_string: gs_md5_append(md5, (const gs_md5_byte_t *)ref1.value.const_bytes, r_size(&ref1)); break; case t_array: case t_mixedarray: case t_shortarray: if (!hasharray(i_ctx_p, &ref1, md5)) return 0; break; case t_oparray: break; case t_operator: gs_md5_append(md5, (const gs_md5_byte_t *)&ref1.value.opproc, sizeof(ref1.value.opproc)); break; case t__invalid: case t_dictionary: case t_file: case t_unused_array_: case t_struct: case t_astruct: case t_fontID: case t_save: case t_mark: case t_device: return 0; default: /* Some high frequency operators are defined starting at t_next_index * I think as long as the 'type' of each is the same, we are OK */ break; } } return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,471
static int hashciedefgspace(i_ctx_t *i_ctx_p, ref *space, gs_md5_state_t *md5) { /* If the problems mentioned above are resolved, then this code could * be re-instated. */ int code = 0; ref CIEdict1, spacename; code = array_get(imemory, space, 0, &spacename); if (code < 0) return 0; gs_md5_append(md5, (const gs_md5_byte_t *)&spacename.value.pname, sizeof(spacename.value.pname)); code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"WhitePoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"BlackPoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeDEFG", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeDEFG", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeHIJK", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"Table", md5)) return 0; return 1; }
null
0
static int hashciedefgspace(i_ctx_t *i_ctx_p, ref *space, gs_md5_state_t *md5) { /* If the problems mentioned above are resolved, then this code could * be re-instated. */ int code = 0; ref CIEdict1, spacename; code = array_get(imemory, space, 0, &spacename); if (code < 0) return 0; gs_md5_append(md5, (const gs_md5_byte_t *)&spacename.value.pname, sizeof(spacename.value.pname)); code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"WhitePoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"BlackPoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeDEFG", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeDEFG", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeHIJK", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"Table", md5)) return 0; return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,472
static int hashciedefspace(i_ctx_t *i_ctx_p, ref *space, gs_md5_state_t *md5) { int code = 0; ref CIEdict1, spacename; code = array_get(imemory, space, 0, &spacename); if (code < 0) return 0; gs_md5_append(md5, (const gs_md5_byte_t *)&spacename.value.pname, sizeof(spacename.value.pname)); code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"WhitePoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"BlackPoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeDEF", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeDEF", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeHIJ", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"Table", md5)) return 0; return 1; }
null
0
static int hashciedefspace(i_ctx_t *i_ctx_p, ref *space, gs_md5_state_t *md5) { int code = 0; ref CIEdict1, spacename; code = array_get(imemory, space, 0, &spacename); if (code < 0) return 0; gs_md5_append(md5, (const gs_md5_byte_t *)&spacename.value.pname, sizeof(spacename.value.pname)); code = array_get(imemory, space, 1, &CIEdict1); if (code < 0) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"WhitePoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"BlackPoint", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixABC", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeLMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"MatrixMN", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeDEF", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"DecodeDEF", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"RangeHIJ", md5)) return 0; if (!hashdictkey(i_ctx_p, &CIEdict1, (char *)"Table", md5)) return 0; return 1; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,473
static int iccalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst) { int components, code = 0; ref *tempref, ICCdict; if (!r_is_array(space)) return_error(gs_error_typecheck); /* Validate parameters, check we have enough operands */ if (r_size(space) != 2) return_error(gs_error_rangecheck); code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); components = tempref->value.intval; code = dict_find_string(&ICCdict, "Alternate", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { *r = tempref; } else { switch (components) { case 1: code = name_enter_string(imemory, "DeviceGray", *r); break; case 3: code = name_enter_string(imemory, "DeviceRGB", *r); break; case 4: code = name_enter_string(imemory, "DeviceCMYK", *r); break; default: return_error(gs_error_rangecheck); } } *CIESubst = 1; return code; }
null
0
static int iccalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst) { int components, code = 0; ref *tempref, ICCdict; if (!r_is_array(space)) return_error(gs_error_typecheck); /* Validate parameters, check we have enough operands */ if (r_size(space) != 2) return_error(gs_error_rangecheck); code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); components = tempref->value.intval; code = dict_find_string(&ICCdict, "Alternate", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { *r = tempref; } else { switch (components) { case 1: code = name_enter_string(imemory, "DeviceGray", *r); break; case 3: code = name_enter_string(imemory, "DeviceRGB", *r); break; case 4: code = name_enter_string(imemory, "DeviceCMYK", *r); break; default: return_error(gs_error_rangecheck); } } *CIESubst = 1; return code; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,474
static int icccomponents(i_ctx_t * i_ctx_p, ref *space, int *n) { int code = 0; ref *tempref, ICCdict; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); *n = tempref->value.intval; return 0; }
null
0
static int icccomponents(i_ctx_t * i_ctx_p, ref *space, int *n) { int code = 0; ref *tempref, ICCdict; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); *n = tempref->value.intval; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,475
static int iccdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int components, i, code = 0; ref *tempref, ICCdict, valref; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); components = tempref->value.intval; code = dict_find_string(&ICCdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<components * 2;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i * 2] = (float)valref.value.intval; else ptr[i * 2] = valref.value.realval; } } else { for (i=0;i<components;i++) { ptr[i * 2] = 0; ptr[(i * 2) + 1] = 1; } } return 0; }
null
0
static int iccdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int components, i, code = 0; ref *tempref, ICCdict, valref; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); components = tempref->value.intval; code = dict_find_string(&ICCdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<components * 2;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i * 2] = (float)valref.value.intval; else ptr[i * 2] = valref.value.realval; } } else { for (i=0;i<components;i++) { ptr[i * 2] = 0; ptr[(i * 2) + 1] = 1; } } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,476
static int iccrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int components, i, code = 0; ref *tempref, ICCdict, valref; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); components = tempref->value.intval; code = dict_find_string(&ICCdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<components * 2;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i] = (float)valref.value.intval; else ptr[i] = (float)valref.value.realval; } } else { for (i=0;i<components;i++) { ptr[i * 2] = 0; ptr[(i * 2) + 1] = 1; } } return 0; }
null
0
static int iccrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int components, i, code = 0; ref *tempref, ICCdict, valref; code = array_get(imemory, space, 1, &ICCdict); if (code < 0) return code; code = dict_find_string(&ICCdict, "N", &tempref); if (code < 0) return code; if (code == 0) return gs_note_error(gs_error_undefined); components = tempref->value.intval; code = dict_find_string(&ICCdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<components * 2;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i] = (float)valref.value.intval; else ptr[i] = (float)valref.value.realval; } } else { for (i=0;i<components;i++) { ptr[i * 2] = 0; ptr[(i * 2) + 1] = 1; } } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,477
static int iccvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { return 0; }
null
0
static int iccvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,478
indexed_cont(i_ctx_t *i_ctx_p) { os_ptr op = osp; es_ptr ep = esp; int i = (int)ep[csme_index].value.intval; if (i >= 0) { /* i.e., not first time */ int m = (int)ep[csme_num_components].value.intval; int code = float_params(op, m, &r_ptr(&ep[csme_map], gs_indexed_map)->values[i * m]); if (code < 0) return code; pop(m); op -= m; if (i == (int)ep[csme_hival].value.intval) { /* All done. */ esp -= num_csme; return o_pop_estack; } } push(1); ep[csme_index].value.intval = ++i; make_int(op, i); make_op_estack(ep + 1, indexed_cont); ep[2] = ep[csme_proc]; /* lookup proc */ esp = ep + 2; return o_push_estack; }
null
0
indexed_cont(i_ctx_t *i_ctx_p) { os_ptr op = osp; es_ptr ep = esp; int i = (int)ep[csme_index].value.intval; if (i >= 0) { /* i.e., not first time */ int m = (int)ep[csme_num_components].value.intval; int code = float_params(op, m, &r_ptr(&ep[csme_map], gs_indexed_map)->values[i * m]); if (code < 0) return code; pop(m); op -= m; if (i == (int)ep[csme_hival].value.intval) { /* All done. */ esp -= num_csme; return o_pop_estack; } } push(1); ep[csme_index].value.intval = ++i; make_int(op, i); make_op_estack(ep + 1, indexed_cont); ep[2] = ep[csme_proc]; /* lookup proc */ esp = ep + 2; return o_push_estack; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,479
static int indexedalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst) { ref alt; int code; code = array_get(imemory, *r, 1, &alt); if (code < 0) return code; ref_assign(*r, &alt); return 0; }
null
0
static int indexedalternatespace(i_ctx_t * i_ctx_p, ref *space, ref **r, int *CIESubst) { ref alt; int code; code = array_get(imemory, *r, 1, &alt); if (code < 0) return code; ref_assign(*r, &alt); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,480
static int indexedbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { int code; if (*stage == 0) { /* Usefully /Indexed can't be the base of any other space, so we know * the current space in the graphics state is this one. */ gs_color_space *pcs; pcs = gs_currentcolorspace(igs); /* Update the counters */ *stage = 1; *cont = 1; /* Indexed spaces can have *either* a procedure or a string for the * lookup. */ if (pcs->params.indexed.use_proc) { es_ptr ep = ++esp; ref proc; /* We have a procedure, set up the continuation to run the * lookup procedure. (The index is already on the operand stack) */ check_estack(1); code = array_get(imemory, space, 3, &proc); if (code < 0) return code; *ep = proc; /* lookup proc */ return o_push_estack; } else { int i, index; os_ptr op = osp; unsigned char *ptr = (unsigned char *)pcs->params.indexed.lookup.table.data; *stage = 0; /* We have a string, start by retrieving the index from the op stack */ /* Make sure its an integer! */ if (!r_has_type(op, t_integer)) return_error (gs_error_typecheck); index = op->value.intval; /* And remove it from the stack. */ pop(1); op = osp; /* Make sure we have enough space on the op stack to hold * one value for each component of the alternate space */ push(pcs->params.indexed.n_comps); op -= pcs->params.indexed.n_comps - 1; /* Move along the lookup table, one byte for each component , the * number of times required to get to the lookup for this index */ ptr += index * pcs->params.indexed.n_comps; /* For all the components of the alternate space, push the value * of the component on the stack. The value is given by the byte * from the lookup table divided by 255 to give a value between * 0 and 1. */ for (i = 0; i < pcs->params.indexed.n_comps; i++, op++) { float rval = (*ptr++) / 255.0; make_real(op, rval); } return 0; } } else { *stage = 0; *cont = 1; return 0; } }
null
0
static int indexedbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { int code; if (*stage == 0) { /* Usefully /Indexed can't be the base of any other space, so we know * the current space in the graphics state is this one. */ gs_color_space *pcs; pcs = gs_currentcolorspace(igs); /* Update the counters */ *stage = 1; *cont = 1; /* Indexed spaces can have *either* a procedure or a string for the * lookup. */ if (pcs->params.indexed.use_proc) { es_ptr ep = ++esp; ref proc; /* We have a procedure, set up the continuation to run the * lookup procedure. (The index is already on the operand stack) */ check_estack(1); code = array_get(imemory, space, 3, &proc); if (code < 0) return code; *ep = proc; /* lookup proc */ return o_push_estack; } else { int i, index; os_ptr op = osp; unsigned char *ptr = (unsigned char *)pcs->params.indexed.lookup.table.data; *stage = 0; /* We have a string, start by retrieving the index from the op stack */ /* Make sure its an integer! */ if (!r_has_type(op, t_integer)) return_error (gs_error_typecheck); index = op->value.intval; /* And remove it from the stack. */ pop(1); op = osp; /* Make sure we have enough space on the op stack to hold * one value for each component of the alternate space */ push(pcs->params.indexed.n_comps); op -= pcs->params.indexed.n_comps - 1; /* Move along the lookup table, one byte for each component , the * number of times required to get to the lookup for this index */ ptr += index * pcs->params.indexed.n_comps; /* For all the components of the alternate space, push the value * of the component on the stack. The value is given by the byte * from the lookup table divided by 255 to give a value between * 0 and 1. */ for (i = 0; i < pcs->params.indexed.n_comps; i++, op++) { float rval = (*ptr++) / 255.0; make_real(op, rval); } return 0; } } else { *stage = 0; *cont = 1; return 0; } }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,481
static int indexeddomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ref hival; int code; code = array_get(imemory, space, 2, &hival); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)hival.value.intval; return 0; }
null
0
static int indexeddomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ref hival; int code; code = array_get(imemory, space, 2, &hival); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)hival.value.intval; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,482
static int indexedrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ref hival; int code; code = array_get(imemory, space, 2, &hival); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)hival.value.intval; return 0; }
null
0
static int indexedrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ref hival; int code; code = array_get(imemory, space, 2, &hival); if (code < 0) return code; ptr[0] = 0; ptr[1] = (float)hival.value.intval; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,483
static int indexedvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { int code, integer; float fraction; ref hival; os_ptr op = osp; if (num_comps < 1) return_error(gs_error_stackunderflow); if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); code = array_get(imemory, space, 2, &hival); if (code < 0) return code; if (*values > hival.value.intval) *values = (float)hival.value.intval; if (*values < 0) *values = 0; /* The PLRM says 'If it is a real number, it is rounded to the nearest integer * but in fact Acrobat simply floors the value. * * KAS 29/08/2017 the comment above is incorrect, at least for recent versions of Acrobat. * In addition the PDF 2.0 specification states that real numbers should be rounded to * the nearest integer (0.5 rounds up) and if it is outside 0->hival then it should * be adjusted to the nearest value within that range (which is done above). The Quality * Logic 2.0 FTS includes a test for this which Acrobat X fails. */ integer = (int)floor(*values); fraction = *values - integer; if (fraction >= 0.5) *values = (float)(integer + 1); else *values = (float)integer; return 0; }
null
0
static int indexedvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { int code, integer; float fraction; ref hival; os_ptr op = osp; if (num_comps < 1) return_error(gs_error_stackunderflow); if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); code = array_get(imemory, space, 2, &hival); if (code < 0) return code; if (*values > hival.value.intval) *values = (float)hival.value.intval; if (*values < 0) *values = 0; /* The PLRM says 'If it is a real number, it is rounded to the nearest integer * but in fact Acrobat simply floors the value. * * KAS 29/08/2017 the comment above is incorrect, at least for recent versions of Acrobat. * In addition the PDF 2.0 specification states that real numbers should be rounded to * the nearest integer (0.5 rounds up) and if it is outside 0->hival then it should * be adjusted to the nearest value within that range (which is done above). The Quality * Logic 2.0 FTS includes a test for this which Acrobat X fails. */ integer = (int)floor(*values); fraction = *values - integer; if (fraction >= 0.5) *values = (float)(integer + 1); else *values = (float)integer; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,484
static int labbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op; int i, components=1; components = 3; pop(components); op = osp; components = 3; push(components); op -= components-1; for (i=0;i<components;i++) { make_real(op, (float)0); op++; } *stage = 0; *cont = 0; return 0; }
null
0
static int labbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op; int i, components=1; components = 3; pop(components); op = osp; components = 3; push(components); op -= components-1; for (i=0;i<components;i++) { make_real(op, (float)0); op++; } *stage = 0; *cont = 0; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,485
static int labdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, code; ref CIEdict, *tempref, valref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a Range, get the values from that */ code = dict_find_string(&CIEdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<4;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) ptr[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); } } else { /* Default values for Lab */ for (i=0;i<2;i++) { ptr[2 * i] = -100; ptr[(2 * i) + 1] = 100; } } return 0; }
null
0
static int labdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, code; ref CIEdict, *tempref, valref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a Range, get the values from that */ code = dict_find_string(&CIEdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<4;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) ptr[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); } } else { /* Default values for Lab */ for (i=0;i<2;i++) { ptr[2 * i] = -100; ptr[(2 * i) + 1] = 100; } } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,486
static int labrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, code; ref CIEdict, *tempref, valref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a Range entry, get the values from that */ code = dict_find_string(&CIEdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<4;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) ptr[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); } } else { /* Default values for Lab */ for (i=0;i<2;i++) { ptr[2 * i] = -100; ptr[(2 * i) + 1] = 100; } } return 0; }
null
0
static int labrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i, code; ref CIEdict, *tempref, valref; code = array_get(imemory, space, 1, &CIEdict); if (code < 0) return code; /* If we have a Range entry, get the values from that */ code = dict_find_string(&CIEdict, "Range", &tempref); if (code > 0 && !r_has_type(tempref, t_null)) { for (i=0;i<4;i++) { code = array_get(imemory, tempref, i, &valref); if (code < 0) return code; if (r_has_type(&valref, t_integer)) ptr[i] = (float)valref.value.intval; else if (r_has_type(&valref, t_real)) ptr[i] = (float)valref.value.realval; else return_error(gs_error_typecheck); } } else { /* Default values for Lab */ for (i=0;i<2;i++) { ptr[2 * i] = -100; ptr[(2 * i) + 1] = 100; } } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,487
static int onecomponent(i_ctx_t * i_ctx_p, ref *space, int *n) { *n = 1; return 0; }
null
0
static int onecomponent(i_ctx_t * i_ctx_p, ref *space, int *n) { *n = 1; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,488
static int patternbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op; int i, components=0; if (r_size(space) > 1) { const gs_color_space * pcs = gs_currentcolorspace(igs); const gs_client_color * pcc = gs_currentcolor(igs); int n = cs_num_components(pcs); bool push_pattern = n < 0; gs_pattern_instance_t * pinst = pcc->pattern; if (pinst != 0 && pattern_instance_uses_base_space(pinst)) { /* check for pattern */ if (push_pattern) pop(1); /* The pattern instance */ *stage = 0; *cont = 1; return 0; } /* If the pattern isn't yet initialised, or doesn't use the * base space, treat as uncolored and return defaults below * Fall Through. */ } pop(1); op = osp; switch(base) { case 0: components = 1; break; case 1: case 2: components = 3; break; case 3: components = 4; break; } push(components); op -= components-1; for (i=0;i<components;i++) { make_real(op, (float)0); op++; } if (components == 4) { op--; make_real(op, (float)1); } *stage = 0; *cont = 0; return 0; }
null
0
static int patternbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op; int i, components=0; if (r_size(space) > 1) { const gs_color_space * pcs = gs_currentcolorspace(igs); const gs_client_color * pcc = gs_currentcolor(igs); int n = cs_num_components(pcs); bool push_pattern = n < 0; gs_pattern_instance_t * pinst = pcc->pattern; if (pinst != 0 && pattern_instance_uses_base_space(pinst)) { /* check for pattern */ if (push_pattern) pop(1); /* The pattern instance */ *stage = 0; *cont = 1; return 0; } /* If the pattern isn't yet initialised, or doesn't use the * base space, treat as uncolored and return defaults below * Fall Through. */ } pop(1); op = osp; switch(base) { case 0: components = 1; break; case 1: case 2: components = 3; break; case 3: components = 4; break; } push(components); op -= components-1; for (i=0;i<components;i++) { make_real(op, (float)0); op++; } if (components == 4) { op--; make_real(op, (float)1); } *stage = 0; *cont = 0; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,489
static int patterncomponent(i_ctx_t * i_ctx_p, ref *space, int *n) { os_ptr op = osp; int n_comps, code; const gs_color_space * pcs = gs_currentcolorspace(igs); gs_client_color cc; /* check for a pattern color space */ if ((n_comps = cs_num_components(pcs)) < 0) { n_comps = -n_comps; if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; code = dict_find_string(op, "Implementation", &pImpl); if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code; cc.pattern = r_ptr(&pPatInst, gs_pattern_instance_t); if (pattern_instance_uses_base_space(cc.pattern)) *n = n_comps; else *n = 1; } else *n = 1; } else *n = 1; } else return_error(gs_error_typecheck); return 0; }
null
0
static int patterncomponent(i_ctx_t * i_ctx_p, ref *space, int *n) { os_ptr op = osp; int n_comps, code; const gs_color_space * pcs = gs_currentcolorspace(igs); gs_client_color cc; /* check for a pattern color space */ if ((n_comps = cs_num_components(pcs)) < 0) { n_comps = -n_comps; if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; code = dict_find_string(op, "Implementation", &pImpl); if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code; cc.pattern = r_ptr(&pPatInst, gs_pattern_instance_t); if (pattern_instance_uses_base_space(cc.pattern)) *n = n_comps; else *n = 1; } else *n = 1; } else *n = 1; } else return_error(gs_error_typecheck); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,490
static int patternvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; check_op(1); if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) return_error(gs_error_typecheck); return 0; }
null
0
static int patternvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; check_op(1); if (!r_has_type(op, t_dictionary) && !r_has_type(op, t_null)) return_error(gs_error_typecheck); return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,491
static int rgbbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; float RGB[3], CMYK[4], Gray, UCR, BG; int i; const gs_color_space * pcs = gs_currentcolorspace(igs); if (pcs->id == cs_DeviceGray_id) { /* UGLY hack. Its possible for the graphics library to change the * colour space to DeviceGray (setcachedevice), but this does not * change the PostScript space. It can't, because the graphics library * doesn't know about the PostScript objects. If we get a current* * operation before the space has been restored, the colour space in * the graphics library and the PostScript stored space won't match. * If that happens then we need to pretend the PS colour space was * DeviceGray */ return(graybasecolor(i_ctx_p, space, base, stage, cont, stack_depth)); } switch (*stage) { case 0: *cont = 0; check_op(3); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { RGB[i] = op->value.realval; } else return_error(gs_error_typecheck); } else RGB[i] = (float)op->value.intval; if (RGB[i] < 0 || RGB[i] > 1) return_error(gs_error_rangecheck); op++; } op = osp; switch (base) { case 0: pop(2); op = osp; /* If R == G == B, then this is gray, so just use it. Avoids * rounding errors. */ if (RGB[0] == RGB[1] && RGB[1] == RGB[2]) Gray = RGB[0]; else Gray = (0.3 * RGB[0]) + (0.59 * RGB[1]) + (0.11 * RGB[2]); make_real(op, Gray); return 0; break; case 1: rgb2hsb((float *)&RGB); make_real(&op[-2], RGB[0]); make_real(&op[-1], RGB[1]); make_real(op, RGB[2]); return 0; break; case 2: make_real(&op[-2], RGB[0]); make_real(&op[-1], RGB[1]); make_real(op, RGB[2]); return 0; break; case 3: *stage = 1; *cont = 1; for (i=0;i<3;i++) CMYK[i] = 1 - RGB[i]; if (CMYK[0] < CMYK[1]) { if (CMYK[0] < CMYK[2]) CMYK[3] = CMYK[0]; else CMYK[3] = CMYK[2]; } else { if (CMYK[1] < CMYK[2]) CMYK[3] = CMYK[1]; else CMYK[3] = CMYK[2]; } check_estack(1); push(2); op = osp - 4; for (i=0;i<4;i++) { make_real(op, CMYK[i]); op++; } make_real(op, CMYK[3]); esp++; *esp = istate->undercolor_removal; return o_push_estack; break; default: return_error(gs_error_undefined); break; } break; case 1: (*stage)++; *cont = 1; check_estack(1); check_op(5); op -= 4; for (i=0;i<4;i++) { if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { CMYK[i] = op->value.realval; } else return_error(gs_error_typecheck); } else CMYK[i] = (float)op->value.intval; op++; } if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { UCR = op->value.realval; } else return_error(gs_error_typecheck); } else UCR = (float)op->value.intval; for (i=0;i<3;i++) { CMYK[i] = CMYK[i] - UCR; if (CMYK[i] < 0) CMYK[i] = 0; if (CMYK[i] > 1) CMYK[i] = 1.0; } op -= 4; for (i=0;i<4;i++) { make_real(op, CMYK[i]); op++; } make_real(op, CMYK[3]); esp++; *esp = istate->black_generation; return o_push_estack; break; case 2: *stage = 0; *cont = 0; check_op(5); if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { BG = op->value.realval; } else return_error(gs_error_typecheck); } else BG = (float)op->value.intval; pop(1); op = osp; if (BG < 0) BG = 0; if (BG > 1) BG = 1; make_real(op, BG); break; } return 0; }
null
0
static int rgbbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; float RGB[3], CMYK[4], Gray, UCR, BG; int i; const gs_color_space * pcs = gs_currentcolorspace(igs); if (pcs->id == cs_DeviceGray_id) { /* UGLY hack. Its possible for the graphics library to change the * colour space to DeviceGray (setcachedevice), but this does not * change the PostScript space. It can't, because the graphics library * doesn't know about the PostScript objects. If we get a current* * operation before the space has been restored, the colour space in * the graphics library and the PostScript stored space won't match. * If that happens then we need to pretend the PS colour space was * DeviceGray */ return(graybasecolor(i_ctx_p, space, base, stage, cont, stack_depth)); } switch (*stage) { case 0: *cont = 0; check_op(3); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { RGB[i] = op->value.realval; } else return_error(gs_error_typecheck); } else RGB[i] = (float)op->value.intval; if (RGB[i] < 0 || RGB[i] > 1) return_error(gs_error_rangecheck); op++; } op = osp; switch (base) { case 0: pop(2); op = osp; /* If R == G == B, then this is gray, so just use it. Avoids * rounding errors. */ if (RGB[0] == RGB[1] && RGB[1] == RGB[2]) Gray = RGB[0]; else Gray = (0.3 * RGB[0]) + (0.59 * RGB[1]) + (0.11 * RGB[2]); make_real(op, Gray); return 0; break; case 1: rgb2hsb((float *)&RGB); make_real(&op[-2], RGB[0]); make_real(&op[-1], RGB[1]); make_real(op, RGB[2]); return 0; break; case 2: make_real(&op[-2], RGB[0]); make_real(&op[-1], RGB[1]); make_real(op, RGB[2]); return 0; break; case 3: *stage = 1; *cont = 1; for (i=0;i<3;i++) CMYK[i] = 1 - RGB[i]; if (CMYK[0] < CMYK[1]) { if (CMYK[0] < CMYK[2]) CMYK[3] = CMYK[0]; else CMYK[3] = CMYK[2]; } else { if (CMYK[1] < CMYK[2]) CMYK[3] = CMYK[1]; else CMYK[3] = CMYK[2]; } check_estack(1); push(2); op = osp - 4; for (i=0;i<4;i++) { make_real(op, CMYK[i]); op++; } make_real(op, CMYK[3]); esp++; *esp = istate->undercolor_removal; return o_push_estack; break; default: return_error(gs_error_undefined); break; } break; case 1: (*stage)++; *cont = 1; check_estack(1); check_op(5); op -= 4; for (i=0;i<4;i++) { if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { CMYK[i] = op->value.realval; } else return_error(gs_error_typecheck); } else CMYK[i] = (float)op->value.intval; op++; } if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { UCR = op->value.realval; } else return_error(gs_error_typecheck); } else UCR = (float)op->value.intval; for (i=0;i<3;i++) { CMYK[i] = CMYK[i] - UCR; if (CMYK[i] < 0) CMYK[i] = 0; if (CMYK[i] > 1) CMYK[i] = 1.0; } op -= 4; for (i=0;i<4;i++) { make_real(op, CMYK[i]); op++; } make_real(op, CMYK[3]); esp++; *esp = istate->black_generation; return o_push_estack; break; case 2: *stage = 0; *cont = 0; check_op(5); if (!r_has_type(op, t_integer)) { if (r_has_type(op, t_real)) { BG = op->value.realval; } else return_error(gs_error_typecheck); } else BG = (float)op->value.intval; pop(1); op = osp; if (BG < 0) BG = 0; if (BG > 1) BG = 1; make_real(op, BG); break; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,492
static int rgbdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i; for (i = 0;i < 6;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
null
0
static int rgbdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i; for (i = 0;i < 6;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,493
static int rgbrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i; for (i = 0;i < 6;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
null
0
static int rgbrange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { int i; for (i = 0;i < 6;i+=2) { ptr[i] = 0; ptr[i+1] = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,494
static int rgbvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 3) return_error(gs_error_stackunderflow); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } for (i=0;i < 3; i++) { if (values[i] > 1.0) values[i] = 1.0; if (values[i] < 0.0) values[i] = 0.0; } return 0; }
null
0
static int rgbvalidate(i_ctx_t *i_ctx_p, ref *space, float *values, int num_comps) { os_ptr op = osp; int i; if (num_comps < 3) return_error(gs_error_stackunderflow); op -= 2; for (i=0;i<3;i++) { if (!r_has_type(op, t_integer) && !r_has_type(op, t_real)) return_error(gs_error_typecheck); op++; } for (i=0;i < 3; i++) { if (values[i] > 1.0) values[i] = 1.0; if (values[i] < 0.0) values[i] = 0.0; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,495
static int sepbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; /* required by "push" macro */ int use, code; code = septransform(i_ctx_p, space, &use, stage, stack_depth); if (code != 0) return code; if (!use) { *stage = 0; *cont = 0; pop(1); op = osp; switch(base) { case 0: push(1); make_real(op, 0.0); break; case 1: case 2: push(3); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; case 3: push(4); make_real(&op[-3], 0.0); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; } } else { *stage = 0; *cont = 1; } return 0; }
null
0
static int sepbasecolor(i_ctx_t * i_ctx_p, ref *space, int base, int *stage, int *cont, int *stack_depth) { os_ptr op = osp; /* required by "push" macro */ int use, code; code = septransform(i_ctx_p, space, &use, stage, stack_depth); if (code != 0) return code; if (!use) { *stage = 0; *cont = 0; pop(1); op = osp; switch(base) { case 0: push(1); make_real(op, 0.0); break; case 1: case 2: push(3); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; case 3: push(4); make_real(&op[-3], 0.0); make_real(&op[-2], 0.0); make_real(&op[-1], 0.0); make_real(op, 0.0); break; } } else { *stage = 0; *cont = 1; } return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,496
static int sepcompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { ref sname1, sname2; int code; code = array_get(imemory, space, 1, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &sname2); if (code < 0) return 0; if (r_type(&sname1) != r_type(&sname2)) return 0; switch(r_type(&sname1)) { case t_name: if (!name_eq(&sname1, &sname2)) return 0; break; case t_string: if (r_size(&sname1) != r_size(&sname2)) return 0; if (strncmp((const char *)sname1.value.const_bytes, (const char *)sname2.value.const_bytes, r_size(&sname1)) != 0) return 0; break; default: return 0; } code = array_get(imemory, testspace, 2, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 2, &sname2); if (code < 0) return 0; if (r_type(&sname1) != r_type(&sname2)) return 0; if (r_is_array(&sname1)) { if (!comparearrays(i_ctx_p, &sname1, &sname2)) return 0; } else { if (!r_has_type(&sname1, t_name)) return 0; if (!name_eq(&sname1, &sname2)) return 0; } code = array_get(imemory, space, 3, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 3, &sname2); if (code < 0) return 0; return(comparearrays(i_ctx_p, &sname1, &sname2)); }
null
0
static int sepcompareproc(i_ctx_t *i_ctx_p, ref *space, ref *testspace) { ref sname1, sname2; int code; code = array_get(imemory, space, 1, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 1, &sname2); if (code < 0) return 0; if (r_type(&sname1) != r_type(&sname2)) return 0; switch(r_type(&sname1)) { case t_name: if (!name_eq(&sname1, &sname2)) return 0; break; case t_string: if (r_size(&sname1) != r_size(&sname2)) return 0; if (strncmp((const char *)sname1.value.const_bytes, (const char *)sname2.value.const_bytes, r_size(&sname1)) != 0) return 0; break; default: return 0; } code = array_get(imemory, testspace, 2, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 2, &sname2); if (code < 0) return 0; if (r_type(&sname1) != r_type(&sname2)) return 0; if (r_is_array(&sname1)) { if (!comparearrays(i_ctx_p, &sname1, &sname2)) return 0; } else { if (!r_has_type(&sname1, t_name)) return 0; if (!name_eq(&sname1, &sname2)) return 0; } code = array_get(imemory, space, 3, &sname1); if (code < 0) return 0; code = array_get(imemory, testspace, 3, &sname2); if (code < 0) return 0; return(comparearrays(i_ctx_p, &sname1, &sname2)); }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,497
static int sepdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
null
0
static int sepdomain(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,498
static int sepinitialproc(i_ctx_t *i_ctx_p, ref *space) { gs_client_color cc; cc.pattern = 0x00; cc.paint.values[0] = 1.0; return gs_setcolor(igs, &cc); }
null
0
static int sepinitialproc(i_ctx_t *i_ctx_p, ref *space) { gs_client_color cc; cc.pattern = 0x00; cc.paint.values[0] = 1.0; return gs_setcolor(igs, &cc); }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null
2,499
static int seprange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
null
0
static int seprange(i_ctx_t * i_ctx_p, ref *space, float *ptr) { ptr[0] = 0; ptr[1] = 1; return 0; }
@@ -283,8 +283,9 @@ zsetcolor(i_ctx_t * i_ctx_p) if (r_has_type(op, t_dictionary)) { ref *pImpl, pPatInst; - code = dict_find_string(op, "Implementation", &pImpl); - if (code != 0) { + if ((code = dict_find_string(op, "Implementation", &pImpl)) < 0) + return code; + if (code > 0) { code = array_get(imemory, pImpl, 0, &pPatInst); if (code < 0) return code;
CWE-704
null
null