Skip to content

Commit 4ac7802

Browse files
brammooldouglaskayama
authored andcommitted
patch 7.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)
1 parent ac5e928 commit 4ac7802

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/hardcopy.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,21 +2513,29 @@ mch_print_init(psettings, jobname, forceit)
25132513
props = enc_canon_props(p_encoding);
25142514
if (!(props & ENC_8BIT) && ((*p_pmcs != NUL) || !(props & ENC_UNICODE)))
25152515
{
2516+
int cmap_first;
2517+
25162518
p_mbenc_first = NULL;
25172519
for (cmap = 0; cmap < (int)NUM_ELEMENTS(prt_ps_mbfonts); cmap++)
25182520
if (prt_match_encoding((char *)p_encoding, &prt_ps_mbfonts[cmap],
25192521
&p_mbenc))
25202522
{
25212523
if (p_mbenc_first == NULL)
2524+
{
25222525
p_mbenc_first = p_mbenc;
2526+
cmap_first = cmap;
2527+
}
25232528
if (prt_match_charset((char *)p_pmcs, &prt_ps_mbfonts[cmap],
25242529
&p_mbchar))
25252530
break;
25262531
}
25272532

25282533
/* Use first encoding matched if no charset matched */
25292534
if (p_mbchar == NULL && p_mbenc_first != NULL)
2535+
{
25302536
p_mbenc = p_mbenc_first;
2537+
cmap = cmap_first;
2538+
}
25312539
}
25322540

25332541
prt_out_mbyte = (p_mbenc != NULL);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ static char *(features[]) =
756756

757757
static int included_patches[] =
758758
{ /* Add new patch number below this line */
759+
/**/
760+
695,
759761
/**/
760762
694,
761763
/**/

0 commit comments

Comments
 (0)