]> granicus.if.org Git - vim/commitdiff
patch 7.4.695 v7.4.695
authorBram Moolenaar <Bram@vim.org>
Mon, 13 Apr 2015 12:45:27 +0000 (14:45 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 13 Apr 2015 12:45:27 +0000 (14:45 +0200)
Problem:    Out-of-bounds read, dectected by Coverity.
Solution:   Remember the value of cmap for the first matching encoding.  Reset
            cmap to that value if first matching encoding is going to be used.
            (Eliseo Martínez)

src/hardcopy.c
src/version.c

index 95a367d496909de57373735fcc7c6ef2bb1e7311..b2e400f9069f85878a880be694bbd20e61cc2489 100644 (file)
@@ -2513,13 +2513,18 @@ mch_print_init(psettings, jobname, forceit)
     props = enc_canon_props(p_encoding);
     if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE)))
     {
+       int cmap_first;
+
        p_mbenc_first = NULL;
        for (cmap = 0; cmap < (int)NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
            if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
                                                                    &p_mbenc))
            {
                if (p_mbenc_first == NULL)
+               {
                    p_mbenc_first = p_mbenc;
+                   cmap_first = cmap;
+               }
                if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap],
                                                                   &p_mbchar))
                    break;
@@ -2527,7 +2532,10 @@ mch_print_init(psettings, jobname, forceit)
 
        /* Use first encoding matched if no charset matched */
        if (p_mbchar == NULL && p_mbenc_first != NULL)
+       {
            p_mbenc = p_mbenc_first;
+           cmap = cmap_first;
+       }
     }
 
     prt_out_mbyte = (p_mbenc != NULL);
index 5601c0144931b1a226c5e75e4f68e55ac09656d1..4cbf4b6ae3f4b6215c810550dd436ed84b8c8149 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    695,
 /**/
     694,
 /**/