Mercurial > vim
comparison src/hardcopy.c @ 27453:c7f614c9ceb3 v8.2.4255
patch 8.2.4255: theoretical computation overflow
Commit: https://github.com/vim/vim/commit/d5cec1f1f055316c353cfa15ad8d5eb0952d50a0
Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com>
Date: Sat Jan 29 15:19:23 2022 +0000
patch 8.2.4255: theoretical computation overflow
Problem: Theoretical computation overflow.
Solution: Perform multiplication in a wider type. (closes https://github.com/vim/vim/issues/9657)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Jan 2022 16:30:03 +0100 |
parents | c9474ae175f4 |
children | fb4c30606b4a |
comparison
equal
deleted
inserted
replaced
27452:81af1f0ff8ce | 27453:c7f614c9ceb3 |
---|---|
2767 { | 2767 { |
2768 // In portrait printing the fixed point is the top left corner so we | 2768 // In portrait printing the fixed point is the top left corner so we |
2769 // derive the bbox from that point. We have the expected cpl chars | 2769 // derive the bbox from that point. We have the expected cpl chars |
2770 // across the media and lpp lines down the media. | 2770 // across the media and lpp lines down the media. |
2771 bbox[1] = (int)(top - (psettings->lines_per_page + prt_header_height()) | 2771 bbox[1] = (int)(top - (psettings->lines_per_page + prt_header_height()) |
2772 * prt_line_height); | 2772 * (double)prt_line_height); |
2773 bbox[2] = (int)(left + psettings->chars_per_line * prt_char_width | 2773 bbox[2] = (int)(left + psettings->chars_per_line |
2774 + 0.5); | 2774 * (double)prt_char_width + 0.5); |
2775 bbox[3] = (int)(top + 0.5); | 2775 bbox[3] = (int)(top + 0.5); |
2776 } | 2776 } |
2777 else | 2777 else |
2778 { | 2778 { |
2779 // In landscape printing the fixed point is the bottom left corner so we | 2779 // In landscape printing the fixed point is the bottom left corner so we |
2780 // derive the bbox from that point. We have lpp chars across the media | 2780 // derive the bbox from that point. We have lpp chars across the media |
2781 // and cpl lines up the media. | 2781 // and cpl lines up the media. |
2782 bbox[1] = (int)bottom; | 2782 bbox[1] = (int)bottom; |
2783 bbox[2] = (int)(left + ((psettings->lines_per_page | 2783 bbox[2] = (int)(left + ((psettings->lines_per_page |
2784 + prt_header_height()) * prt_line_height) + 0.5); | 2784 + prt_header_height()) * prt_line_height) + 0.5); |
2785 bbox[3] = (int)(bottom + psettings->chars_per_line * prt_char_width | 2785 bbox[3] = (int)(bottom + psettings->chars_per_line |
2786 + 0.5); | 2786 * (double)prt_char_width + 0.5); |
2787 } | 2787 } |
2788 prt_dsc_ints("BoundingBox", 4, bbox); | 2788 prt_dsc_ints("BoundingBox", 4, bbox); |
2789 // The media width and height does not change with landscape printing! | 2789 // The media width and height does not change with landscape printing! |
2790 prt_dsc_docmedia(prt_mediasize[prt_media].name, | 2790 prt_dsc_docmedia(prt_mediasize[prt_media].name, |
2791 prt_mediasize[prt_media].width, | 2791 prt_mediasize[prt_media].width, |
2795 if (!prt_out_mbyte || prt_use_courier) | 2795 if (!prt_out_mbyte || prt_use_courier) |
2796 prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font); | 2796 prt_dsc_font_resource("DocumentNeededResources", &prt_ps_courier_font); |
2797 if (prt_out_mbyte) | 2797 if (prt_out_mbyte) |
2798 { | 2798 { |
2799 prt_dsc_font_resource((prt_use_courier ? NULL | 2799 prt_dsc_font_resource((prt_use_courier ? NULL |
2800 : "DocumentNeededResources"), &prt_ps_mb_font); | 2800 : "DocumentNeededResources"), &prt_ps_mb_font); |
2801 if (!prt_custom_cmap) | 2801 if (!prt_custom_cmap) |
2802 prt_dsc_resources(NULL, "cmap", prt_cmap); | 2802 prt_dsc_resources(NULL, "cmap", prt_cmap); |
2803 } | 2803 } |
2804 | 2804 |
2805 // Search for external resources VIM supplies | 2805 // Search for external resources VIM supplies |