Commit 06e151be for tesseract

commit 06e151be9530e6ef3f5cd3a984e1d4f7b72283ea
Author: Stefan Weil <sw@weilnetz.de>
Date:   Fri Nov 13 17:30:49 2026 +0100

    lstm: zero the back deltas in Reconfig::Backward

    Forward() truncates the output map, so input rows and columns which do
    not fill a whole tile of x_scale by y_scale have no part in the
    output. Backward() resizes back_deltas to the full input map without
    initializing it and then only writes the positions of whole tiles. The
    other positions kept old heap contents, which the layer below added to
    its weights during training.

    Zero the buffer after resizing it, as the Maxpool code does.

    Fix proposed by the Anthropic OSS Scanner (finding ANT-2026-T3JM0HM1).

    Assisted-by: OpenCode / Claude Fable 5.2 (Anthropic)
    Signed-off-by: Stefan Weil <sw@weilnetz.de>

diff --git a/src/lstm/reconfig.cpp b/src/lstm/reconfig.cpp
index 348ad60a..121359a3 100644
--- a/src/lstm/reconfig.cpp
+++ b/src/lstm/reconfig.cpp
@@ -112,6 +112,9 @@ void Reconfig::Forward(bool /*debug*/, const NetworkIO &input,
 bool Reconfig::Backward(bool /*debug*/, const NetworkIO &fwd_deltas, NetworkScratch * /*scratch*/,
                         NetworkIO *back_deltas) {
   back_deltas->ResizeToMap(fwd_deltas.int_mode(), back_map_, ni_);
+  // Input rows and columns that do not fill a whole x_scale_ by y_scale_ tile
+  // had no part in the output, so nothing is copied to them below.
+  back_deltas->Zero();
   StrideMap::Index src_index(fwd_deltas.stride_map());
   do {
     int in_t = src_index.t();