~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/cups-raster-fix-memory-reallocation.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2010-04-29 09:43:23 UTC
  • Revision ID: james.westby@ubuntu.com-20100429094323-w8jrv266bj1ynnw5
Tags: 8.71.dfsg.1-0ubuntu5.1
debian/patches/pdf-interpreter-segfault-fixes.dpatch,
debian/patches/cups-raster-fixes.dpatch,
debian/patches/fapi-buildchar-object-null-check.dpatch,
debian/patches/cups-raster-error-out-without-segfault-and-force-banding.dpatch,
debian/patches/cups-raster-fix-memory-reallocation.dpatch: Fixed several
problems in the PDF interpreter and the CUPS Raster output device of
Ghostscript to avoid Ghostscript erroring out or even crashing on many
input files when printing with a CUPS Raster driver (LP: 539708, upstream
bug #691014). Joined all changes on cups/gdevcups.c into one patch as
the patches are overlapping and parts of the old patches are undone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh /usr/share/dpatch/dpatch-run
2
 
## cups-raster-fix-memory-reallocation.dpatch by  <till.kamppeter@gmail.com>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
@DPATCH@
8
 
diff -urNad ghostscript-8.71.dfsg.1~/cups/gdevcups.c ghostscript-8.71.dfsg.1/cups/gdevcups.c
9
 
--- ghostscript-8.71.dfsg.1~/cups/gdevcups.c    2010-01-22 18:46:02.000000000 +0100
10
 
+++ ghostscript-8.71.dfsg.1/cups/gdevcups.c     2010-03-09 17:46:32.415232494 +0100
11
 
@@ -975,7 +975,8 @@
12
 
              frac      k,              /* I - Black value */
13
 
              frac      *out)           /* O - Device colors */
14
 
 {
15
 
-  int  c0, c1, c2, c3;                 /* Temporary color values */
16
 
+  int  c0 = 0, c1 = 0,
17
 
+        c2 = 0, c3 = 0;                        /* Temporary color values */
18
 
   float        rr, rg, rb,                     /* Real RGB colors */
19
 
        ciex, ciey, ciez,               /* CIE XYZ colors */
20
 
        ciey_yn,                        /* Normalized luminance */
21
 
@@ -2703,9 +2704,13 @@
22
 
   int                  color_set;      /* Were the color attrs set? */
23
 
   gdev_prn_space_params        sp;             /* Space parameter data */
24
 
   int                  width,          /* New width of page */
25
 
-                        height;                /* New height of page */
26
 
+                        height,                /* New height of page */
27
 
+                        colorspace,     /* New color space */
28
 
+                        bitspercolor;   /* New bits per color */
29
 
   static int            width_old = 0,  /* Previous width */
30
 
-                        height_old = 0; /* Previous height */
31
 
+                        height_old = 0, /* Previous height */
32
 
+                        colorspace_old = 0,/* Previous color space */
33
 
+                        bitspercolor_old = 0;/* Previous bits per color */
34
 
   ppd_attr_t            *backside = NULL,
35
 
                         *backsiderequiresflippedmargins = NULL;
36
 
   float                 swap;
37
 
@@ -2800,9 +2805,10 @@
38
 
   else if (code == 0) \
39
 
   { \
40
 
     dprintf1("DEBUG: Setting %s to", sname); \
41
 
-    for (i = 0; i < count; i ++) \
42
 
-      dprintf1(" %d", (unsigned)(arrayval.data[i]));    \
43
 
-      cups->header.name[i] = (unsigned)arrayval.data[i]; \
44
 
+    for (i = 0; i < count; i ++) { \
45
 
+      dprintf1(" %d", (unsigned)(arrayval.data[i])); \
46
 
+      cups->header.name[i] = (unsigned)(arrayval.data[i]); \
47
 
+    } \
48
 
     dprintf("...\n"); \
49
 
   }
50
 
 
51
 
@@ -3243,23 +3249,31 @@
52
 
     }
53
 
 #endif /* CUPS_RASTER_SYNCv1 */
54
 
 
55
 
+    colorspace = cups->header.cupsColorSpace;
56
 
+    bitspercolor = cups->header.cupsBitsPerColor;
57
 
+
58
 
    /*
59
 
     * Don't reallocate memory unless the device has been opened...
60
 
     * Also reallocate only if the size has actually changed...
61
 
     */
62
 
 
63
 
-    if (pdev->is_open && (width != width_old || height != height_old))
64
 
+    if (pdev->is_open &&
65
 
+       (width != width_old || height != height_old ||
66
 
+        colorspace != colorspace_old || bitspercolor != bitspercolor_old))
67
 
     {
68
 
 
69
 
       width_old = width;
70
 
       height_old = height;
71
 
+      colorspace_old = colorspace;
72
 
+      bitspercolor_old = bitspercolor;
73
 
 
74
 
      /*
75
 
       * Device is open and size has changed, so reallocate...
76
 
       */
77
 
 
78
 
-      dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n",
79
 
-              pdev->MediaSize[0], pdev->MediaSize[1], width, height);
80
 
+      dprintf6("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels, color space: %d, bits per color: %d...\n",
81
 
+              pdev->MediaSize[0], pdev->MediaSize[1], width, height,
82
 
+              colorspace, bitspercolor);
83
 
 
84
 
       sp = ((gx_device_printer *)pdev)->space_params;
85