From c05330089d27ba789b9a64941b5f4e6265c172c6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 1 Jun 2010 11:51:37 +0000 Subject: [PATCH] From Mathias Froehlich, "While tracking some valgrind problems in flightgear, I found a remaining off by one error in the rgb loader. Previously we limited the current line to the image with + 1. With that change it is correctly limited to the width of the image. Also flightgear seems to run nice with that change. " --- src/osgPlugins/rgb/ReaderWriterRGB.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osgPlugins/rgb/ReaderWriterRGB.cpp b/src/osgPlugins/rgb/ReaderWriterRGB.cpp index 556f65f08..7d23ebd64 100644 --- a/src/osgPlugins/rgb/ReaderWriterRGB.cpp +++ b/src/osgPlugins/rgb/ReaderWriterRGB.cpp @@ -302,9 +302,9 @@ static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z) count = (int)(pixel & 0x7F); // limit the count value to the remiaing row size - if (oPtr + count*raw->bpc > buf + raw->sizeX*raw->bpc) + if (raw->sizeX*raw->bpc <= (oPtr - buf)) { - count = ( (buf + raw->sizeX*raw->bpc) - oPtr ) / raw->bpc; + count = raw->sizeX - (oPtr - buf) / raw->bpc; } if (count<=0)