shithub: puzzles

Download patch

ref: b56c994b721f7cb5c5bcf09c5d695d4ae07d3052
parent: d399a6b23051335ce3107f11822ae352816fcd50
author: Simon Tatham <anakin@pobox.com>
date: Sat Dec 11 08:56:12 EST 2021

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.

--- a/pattern.c
+++ b/pattern.c
@@ -439,6 +439,8 @@
     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;