[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1839-gba5b47d

[email protected] (Julian Smith) Fri, 8 Nov 2019 18:00:12 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  ba5b47dc979ca1590f280f482d432705e9b535bf (commit)
       via  4a3401e5e4f5828c67d7c65f77a3bb0106753649 (commit)
       via  f44249d69a36fa7233504bdb137af9ff5008ec37 (commit)
       via  2029235dc8997314c1925e5786212a6c7331f0cf (commit)
       via  5605c6c6a9677013560a6a3c947f4b100eae4e09 (commit)
      from  95151ae3c3c63100bc7ae958f59b8096e7a0f211 (commit)

----------------------------------------------------------------------
commit ba5b47dc979ca1590f280f482d432705e9b535bf
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 17:40:37 2019 +0000

    Coverity p11408:350177: avoid use of uninitialised state.start.x.
    
    Probably not a problem in practise because we can't get gs_pe_closepat without
    earlier gs_pe_moveto or similar.

diff --git a/base/gdevvec.c b/base/gdevvec.c
index 351228b..7136d76 100644
--- a/base/gdevvec.c
+++ b/base/gdevvec.c
@@ -630,6 +630,11 @@ gdev_vector_dopath_init(gdev_vector_dopath_state_t *state,
         gs_make_scaling(vdev->scale.x, vdev->scale.y, &state->scale_mat);
     }
     state->first = true;
+
+    /* This is purely to prevent Coverity from thinking gdev_vector_dopath()
+    could use uninitialised state->start.x. */
+    state->start.x = 0;
+    state->start.y = 0;
 }
 
 /*

----------------------------------------------------------------------
commit 4a3401e5e4f5828c67d7c65f77a3bb0106753649
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 17:21:38 2019 +0000

    Coverity p11408:350167:  fixed use of uninitialised gp_file*.

diff --git a/base/gpmisc.c b/base/gpmisc.c
index 96052fc..22b1484 100644
--- a/base/gpmisc.c
+++ b/base/gpmisc.c
@@ -770,7 +770,7 @@ gp_open_scratch_file(const gs_memory_t *mem,
                      char              *fname,
                      const char        *mode)
 {
-    gp_file *file;
+    gp_file *file = NULL;
     gs_lib_ctx_t *ctx = mem->gs_lib_ctx;
     gs_fs_list_t *fs = ctx->core->fs;
 

----------------------------------------------------------------------
commit f44249d69a36fa7233504bdb137af9ff5008ec37
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 16:40:00 2019 +0000

    Coverity Coverity p11408:350165: try to stop coverity warning about array of floats.
    
    Coverity complains about passing &float to something that assumes it is
    float[9]. Trying explicit cast of base object to float*.

diff --git a/base/gsicc_create.c b/base/gsicc_create.c
index d073257..5f8df5a 100644
--- a/base/gsicc_create.c
+++ b/base/gsicc_create.c
@@ -1537,7 +1537,7 @@ create_lutAtoBprofile(unsigned char **pp_buffer_in, icHeader *header,
     /* Multiply the matrix in the AtoB object by the cam so that the data
        is in D50 */
     if (lutatobparts->matrix == NULL) {
-        gsicc_create_copy_matrix3(cam, &(temp_matrix.cu.u));
+        gsicc_create_copy_matrix3(cam, (float*) &temp_matrix);
         lutatobparts->matrix = &temp_matrix;
     } else {
         if (yonly) {

----------------------------------------------------------------------
commit 2029235dc8997314c1925e5786212a6c7331f0cf
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 16:25:01 2019 +0000

    Coverity p11408:350164: only call memcpy() if buffers are different.
    
    We could use memmove() instead, but this makes things a little clearer.

diff --git a/pcl/pcl/pcindxed.c b/pcl/pcl/pcindxed.c
index a174c7e..f5ebc75 100644
--- a/pcl/pcl/pcindxed.c
+++ b/pcl/pcl/pcindxed.c
@@ -209,7 +209,12 @@ unshare_indexed_cspace(pcl_cs_indexed_t ** ppindexed)
     memcpy(pnew->pen_widths, pindexed->pen_widths,
            num_entries * sizeof(float));
     memcpy(pnew->norm, pindexed->norm, 3 * sizeof(pindexed->norm[0]));
-    memcpy(pnew->Decode, pindexed->Decode, 6 * sizeof(float));
+
+    /* Coverity thinks next memcpy() might need to be memmove(), so we
+    explicitly check for the buffers being equal. */
+    if (pnew->Decode != pindexed->Decode) {
+        memcpy(pnew->Decode, pindexed->Decode, 6 * sizeof(float));
+    }
 
     return 0;
 }

----------------------------------------------------------------------
commit 5605c6c6a9677013560a6a3c947f4b100eae4e09
Author: Julian Smith <[email protected]>
Date:   Fri Nov 8 12:31:08 2019 +0000

    Coverity p11408:350160: attempt to avoid coverity issues when calling pl_dict_put().
    
    Coverity doesn't like hard-coded 32 for the size of 'short
    unicode_fontname[16]', so use sizeof().

diff --git a/pcl/pl/pllfont.c b/pcl/pl/pllfont.c
index f0b9f19..d2fe927 100644
--- a/pcl/pl/pllfont.c
+++ b/pcl/pl/pllfont.c
@@ -308,7 +308,7 @@ pl_load_ufst_lineprinter(gs_memory_t * mem, pl_dict_t * pfontdict,
             if (use_unicode_names_for_keys)
                 code = pl_dict_put(pfontdict,
                             (const byte *)resident_table[i].unicode_fontname,
-                            32, pplfont);
+                            sizeof(resident_table[i].unicode_fontname), pplfont);
             else {
                 byte key[3];
 
@@ -540,8 +540,9 @@ pl_load_built_in_mtype_fonts(const char *pathname, gs_memory_t * mem,
                     }
                     if (use_unicode_names_for_keys)
                         code = pl_dict_put(pfontdict,
-                                    (const byte *)resident_table[j].
-                                    unicode_fontname, 32, plfont);
+                                    (const byte *)resident_table[j].unicode_fontname,
+                                    sizeof(resident_table[j].unicode_fontname),
+                                    plfont);
                     else {
                         key[2] = (byte) j;
                         key[0] = key[1] = 0;
@@ -702,7 +703,8 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t * mem,
                    residentp->character_complement, 8);
             if (use_unicode_names_for_keys)
                 code = pl_dict_put(pfontdict,
-                                   (const byte *)residentp->unicode_fontname, 32,
+                                   (const byte *)residentp->unicode_fontname,
+                                   sizeof(residentp->unicode_fontname),
                                    plfont);
             else {
                 key[2] = (byte) (residentp - resident_table);


Summary of changes:
 base/gdevvec.c      |  5 +++++
 base/gpmisc.c       |  2 +-
 base/gsicc_create.c |  2 +-
 pcl/pcl/pcindxed.c  |  7 ++++++-
 pcl/pl/pllfont.c    | 10 ++++++----
 5 files changed, 19 insertions(+), 7 deletions(-)