mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Fix bad assert.
Problem : Assert can fail for legal values. Modulo-arithmetic of unsigned types can make so that n * 100 > n, but n has overflowed. Solution : Use alternative form of expression.
This commit is contained in:
parent
9b4f6fbd33
commit
12f606a2a8
@ -14,6 +14,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "nvim/vim.h"
|
||||
#include "nvim/ascii.h"
|
||||
@ -726,8 +727,7 @@ void ex_hardcopy(exarg_T *eap)
|
||||
if (got_int || settings.user_abort)
|
||||
goto print_fail;
|
||||
|
||||
assert(prtpos.bytes_printed == 0
|
||||
|| prtpos.bytes_printed * 100 > prtpos.bytes_printed);
|
||||
assert(prtpos.bytes_printed <= SIZE_MAX / 100);
|
||||
sprintf((char *)IObuff, _("Printing page %d (%zu%%)"),
|
||||
page_count + 1 + side,
|
||||
prtpos.bytes_printed * 100 / bytes_to_print);
|
||||
|
Loading…
Reference in New Issue
Block a user