From b56c994b721f7cb5c5bcf09c5d695d4ae07d3052 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 11 Dec 2021 13:56:12 +0000 Subject: [PATCH] Pattern: fix a compile warning about memset bounds. The argument to memset was being taken from an int variable that not all compilers are able to prove is non-negative. Adding an assert convinces them. --- pattern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pattern.c b/pattern.c index 278bc33..7c00bf9 100644 --- a/pattern.c +++ b/pattern.c @@ -439,6 +439,8 @@ static bool do_row(unsigned char *known, unsigned char *deduced, int rowlen, i, freespace; bool done_any; + assert(len >= 0); /* avoid compile warnings about the memsets below */ + freespace = len+1; for (rowlen = 0; data[rowlen]; rowlen++) { minpos_done[rowlen] = minpos_ok[rowlen] = len - 1;