From 32c7b783de262f21fa5e3f58a59031edf23ab3cb Mon Sep 17 00:00:00 2001
From: Alex Tutubalin <lexa@lexa.ru>
Date: Sat, 28 Feb 2026 18:26:53 +0300
Subject: [PATCH] Fix for TALOS-2026-2331

---
 src/decoders/decoders_dcraw.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: LibRaw-0.21.4/src/decoders/decoders_dcraw.cpp
===================================================================
--- LibRaw-0.21.4.orig/src/decoders/decoders_dcraw.cpp
+++ LibRaw-0.21.4/src/decoders/decoders_dcraw.cpp
@@ -584,6 +584,7 @@ void LibRaw::lossless_jpeg_load_raw()
   if (jh.clrs == 4 && jwide >= raw_width * 2)
     jhigh *= 2;
 
+  
   try
   {
     for (jrow = 0; jrow < jh.high; jrow++)
@@ -612,7 +613,7 @@ void LibRaw::lossless_jpeg_load_raw()
           col += (row--, raw_width);
         if (row > raw_height)
           throw LIBRAW_EXCEPTION_IO_CORRUPT;
-        if ((unsigned)row < raw_height)
+        if (((unsigned)row < raw_height) && ((unsigned)col < raw_width))
           RAW(row, col) = val;
         if (++col >= raw_width)
           col = (row++, 0);
