summaryrefslogtreecommitdiffstats
path: root/src/hardcopy.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-04-13 14:45:27 +0200
committerBram Moolenaar <Bram@vim.org>2015-04-13 14:45:27 +0200
commit7c94ce910f07e0d76d66b46bccfe39a07d8e1f6d (patch)
tree70cff5bf8abb1250cd8921ce3d2762312bbcc402 /src/hardcopy.c
parent83d1b19015219c7799af0a0d539ae86a41057240 (diff)
patch 7.4.695v7.4.695
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)
Diffstat (limited to 'src/hardcopy.c')
-rw-r--r--src/hardcopy.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 95a367d496..b2e400f906 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -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);