File ghostscript-8.62-bnc605043.dif of Package ghostscript-library
--- src/int.mak 2009-11-11 13:37:03 UTC (rev 10311)
+++ src/int.mak 2009-11-11 13:52:23 UTC (rev 10312)
@@ -255,7 +255,7 @@
icontext_h=$(PSSRC)icontext.h $(gsstype_h) $(icstate_h)
ifilter_h=$(PSSRC)ifilter.h $(istream_h) $(ivmspace_h)
igstate_h=$(PSSRC)igstate.h $(gsstate_h) $(gxstate_h) $(imemory_h) $(istruct_h) $(gxcindex_h)
-iscan_h=$(PSSRC)iscan.h $(sa85x_h) $(sstring_h)
+iscan_h=$(PSSRC)iscan.h $(sa85x_h) $(sstring_h) $(inamestr_h)
sbhc_h=$(PSSRC)sbhc.h $(shc_h)
zfile_h=$(PSSRC)zfile.h
# Include files for optional features
--- src/idosave.h (revision 11306)
+++ src/idosave.h (working copy)
@@ -18,6 +18,22 @@
# define idosave_INCLUDED
/*
+ * Structure for saved change chain for save/restore. Because of the
+ * garbage collector, we need to distinguish the cases where the change
+ * is in a static object, a dynamic ref, or a dynamic struct.
+ */
+typedef struct alloc_change_s alloc_change_t;
+struct alloc_change_s {
+ alloc_change_t *next;
+ ref_packed *where;
+ ref contents;
+#define AC_OFFSET_STATIC (-2) /* static object */
+#define AC_OFFSET_REF (-1) /* dynamic ref */
+#define AC_OFFSET_ALLOCATED (-3) /* a newly allocated ref array */
+ short offset; /* if >= 0, offset within struct */
+};
+
+/*
* Save a change that must be undone by restore. We have to pass the
* pointer to the containing object to alloc_save_change for two reasons:
*
@@ -29,6 +45,7 @@
* relocate the pointer to it from the change record during garbage
* collection.
*/
+
int alloc_save_change(gs_dual_memory_t *dmem, const ref *pcont,
ref_packed *ptr, client_name_t cname);
int alloc_save_change_in(gs_ref_memory_t *mem, const ref *pcont,
@@ -36,6 +53,6 @@
/* Remove an AC_OFFSET_ALLOCATED element. */
void alloc_save_remove(gs_ref_memory_t *mem, ref_packed *obj, client_name_t cname);
/* Allocate a structure for recording an allocation event. */
-int alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, ref_packed ***ppr);
+int alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, alloc_change_t **pcp);
#endif /* idosave_INCLUDED */
--- src/isave.c (revision 11306)
+++ src/isave.c (working copy)
@@ -156,22 +156,6 @@
/* A link to igcref.c . */
ptr_proc_reloc(igc_reloc_ref_ptr_nocheck, ref_packed);
-/*
- * Structure for saved change chain for save/restore. Because of the
- * garbage collector, we need to distinguish the cases where the change
- * is in a static object, a dynamic ref, or a dynamic struct.
- */
-typedef struct alloc_change_s alloc_change_t;
-struct alloc_change_s {
- alloc_change_t *next;
- ref_packed *where;
- ref contents;
-#define AC_OFFSET_STATIC (-2) /* static object */
-#define AC_OFFSET_REF (-1) /* dynamic ref */
-#define AC_OFFSET_ALLOCATED (-3) /* a newly allocated ref array */
- short offset; /* if >= 0, offset within struct */
-};
-
static
CLEAR_MARKS_PROC(change_clear_marks)
{
@@ -519,7 +503,7 @@
/* Allocate a structure for recording an allocation event. */
int
-alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, ref_packed ***ppr)
+alloc_save_change_alloc(gs_ref_memory_t *mem, client_name_t cname, alloc_change_t **pcp)
{
register alloc_change_t *cp;
@@ -533,8 +517,7 @@
cp->where = 0;
cp->offset = AC_OFFSET_ALLOCATED;
make_null(&cp->contents);
- mem->changes = cp;
- *ppr = &cp->where;
+ *pcp = cp;
return 1;
}
--- src/ialloc.c (revision 11306)
+++ src/ialloc.c (working copy)
@@ -185,7 +185,14 @@
*/
chunk_t *pcc = mem->pcc;
ref *end;
+ alloc_change_t *cp = 0;
+ int code = 0;
+ if ((gs_memory_t *)mem != mem->stable_memory) {
+ code = alloc_save_change_alloc(mem, "gs_alloc_ref_array", &cp);
+ if (code < 0)
+ return code;
+ }
obj = gs_alloc_struct_array((gs_memory_t *) mem, num_refs + 1,
ref, &st_refs, cname);
if (obj == 0)
@@ -210,14 +217,10 @@
chunk_locate_ptr(obj, &cl);
cl.cp->has_refs = true;
}
- if ((gs_memory_t *)mem != mem->stable_memory) {
- ref_packed **ppr = 0;
- int code = alloc_save_change_alloc(mem, "gs_alloc_ref_array", &ppr);
- if (code < 0)
- return code;
- if (ppr)
- *ppr = (ref_packed *)obj;
- }
+ if (cp) {
+ mem->changes = cp;
+ cp->where = (ref_packed *)obj;
+ }
}
make_array(parr, attrs | mem->space, num_refs, obj);
return 0;
--- src/iscan.c 2009-11-11 13:37:03 UTC (rev 10311)
+++ src/iscan.c 2009-11-11 13:52:23 UTC (rev 10312)
@@ -72,7 +72,7 @@
dynamic_init(da_ptr pda, gs_memory_t *mem)
{
pda->is_dynamic = false;
- pda->limit = pda->buf + da_buf_size;
+ pda->limit = pda->buf + sizeof(pda->buf);
pda->next = pda->base = pda->buf;
pda->memory = mem;
}
@@ -127,7 +127,7 @@
int code;
pda->next = next;
- if (old_size == max_size)
+ if (old_size >= max_size)
return_error(e_limitcheck);
while ((code = dynamic_resize(pda, new_size)) < 0 &&
new_size > old_size
@@ -143,8 +143,12 @@
dynamic_save(da_ptr pda)
{
if (!pda->is_dynamic && pda->base != pda->buf) {
- memcpy(pda->buf, pda->base, da_size(pda));
- pda->next = pda->buf + da_size(pda);
+ int len = da_size(pda);
+
+ if (len > sizeof(pda->buf))
+ len = sizeof(pda->buf);
+ memcpy(pda->buf, pda->base, len);
+ pda->next = pda->buf + len;
pda->base = pda->buf;
}
}
--- src/iscan.h 2009-11-11 13:37:03 UTC (rev 10311)
+++ src/iscan.h 2009-11-11 13:52:23 UTC (rev 10312)
@@ -20,6 +20,7 @@
#include "sa85x.h"
#include "sstring.h"
+#include "inamestr.h"
/*
* Define the state of the scanner. Before calling scan_token initially,
@@ -46,14 +47,12 @@
* or (only while control is inside scan_token) into the source stream buffer.
*/
#define max_comment_line 255 /* max size of an externally processable comment */
-#define max_dsc_line max_comment_line /* backward compatibility */
-#define da_buf_size (max_comment_line + 2)
typedef struct dynamic_area_s {
byte *base;
byte *next;
byte *limit;
bool is_dynamic;
- byte buf[da_buf_size]; /* initial buffer */
+ byte buf[max_name_string]; /* initial buffer, enough for a valid string */
gs_memory_t *memory;
} dynamic_area;