I have absolutely no idea what these changes means, but it was quite
trivial to avoid segfaulting.....
This might mean that we now produce incorrect results or some other
really misleading and stupid problem.
Anyway this avoids the segfault for the given testcase.

Patch attached.

-- 
Regards,
Andreas Henriksson
diff -uriNp -x xmedcon.spec -x aclocal.m4 -x configure 
xmedcon-0.9.9.3/libs/ljpg/huffd.c xmedcon-0.9.9.3-maxnumcol/libs/ljpg/huffd.c
--- xmedcon-0.9.9.3/libs/ljpg/huffd.c   2005-05-16 00:10:20.000000000 +0200
+++ xmedcon-0.9.9.3-maxnumcol/libs/ljpg/huffd.c 2006-12-05 17:44:16.000000000 
+0100
@@ -445,7 +445,7 @@ void DecodeFirstRow (DecompressInfo *dcP
     /*
      * the rest of the first row
      */
-    for (col=1; col<numCOL; col++) {
+    for (col=1; col<numCOL && col<sizeof(*curRowBuf); col++) {
         for (curComp = 0; curComp < compsInScan; curComp++) {
             ci = dcPtr->MCUmembership[curComp];
             compptr = dcPtr->curCompInfo[ci];
@@ -515,6 +515,10 @@ void DecodeImage (DecompressInfo *dcPtr,
     psv         = dcPtr->Ss;
     prevRowBuf  = mcuROW2;
     curRowBuf   = mcuROW1;
+
+    if (numCOL >= sizeof(*curRowBuf)) {
+       numCOL = sizeof(*curRowBuf)-1;
+    }
   
     if (depth == 8) 
                 image8tmp  = (unsigned char  *) *image;

Reply via email to