Forgotten NSBrowser commit.

Fix to make ICNS loading more stable.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26993 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2008-10-31 09:53:21 +00:00
parent 3b4cc1196a
commit a1b47c0986
3 changed files with 28 additions and 6 deletions

View file

@ -1,3 +1,15 @@
2008-10-31 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBitmapImageRep+ICNS.m
(icns_get_image32_with_mask_from_family): Protect against buffer
overfow detected by valgrind.
2008-10-29 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBrowser.m (-drawTitle:inRect:ofColumn:, -dealloc): Set
and unset the ownership of the shared title cell.
Patch by Matt Rice <ratmice@gmail.com>.
2008-10-24 Fred Kiefer <FredKiefer@gmx.de> 2008-10-24 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSMenu.m (-indexOfItemWithTarget:andAction:): Compare the * Source/NSMenu.m (-indexOfItemWithTarget:andAction:): Compare the

View file

@ -327,6 +327,7 @@ static int icns_get_image32_with_mask_from_family(icns_family_t *iconFamily,
int j; int j;
int res; int res;
icns_type_t mask_type; icns_type_t mask_type;
unsigned int imageDataSize;
if (icns_types_equal(type, ICNS_NULL_TYPE)) if (icns_types_equal(type, ICNS_NULL_TYPE))
return 1; return 1;
@ -348,6 +349,7 @@ static int icns_get_image32_with_mask_from_family(icns_family_t *iconFamily,
return 1; return 1;
} }
imageDataSize = iconImage->imageDataSize;
if ((element->elementSize - ICNS_HEADER_SIZE) < if ((element->elementSize - ICNS_HEADER_SIZE) <
3 * iconImage->imageHeight * iconImage->imageWidth) 3 * iconImage->imageHeight * iconImage->imageWidth)
{ {
@ -364,16 +366,18 @@ static int icns_get_image32_with_mask_from_family(icns_family_t *iconFamily,
{ {
icns_byte_t bv = *b++; icns_byte_t bv = *b++;
int runLen; int runLen;
unsigned int index = samplesPerPixel * offset + plane;
if (bv & 0x80) if (bv & 0x80)
{ {
// Compressed run // Compressed run
icns_byte_t val = *b++; icns_byte_t val = *b++;
runLen = bv - 125; runLen = bv - 125;
for (j = 0; j < runLen; j++) for (j = 0; (j < runLen) && (index < imageDataSize); j++)
{ {
iconImage->imageData[samplesPerPixel * (offset + j) iconImage->imageData[index] = val;
+ plane] = val; index += samplesPerPixel;
} }
} }
else else
@ -382,10 +386,10 @@ static int icns_get_image32_with_mask_from_family(icns_family_t *iconFamily,
int j; int j;
runLen = bv + 1; runLen = bv + 1;
for (j = 0; j < runLen; j++) for (j = 0; (j < runLen) && (index < imageDataSize); j++)
{ {
iconImage->imageData[samplesPerPixel * (offset + j) iconImage->imageData[index] = *b++;
+ plane] = *b++; index += samplesPerPixel;
} }
} }

View file

@ -1453,6 +1453,7 @@ static NSTextFieldCell *titleCell;
if (!_isTitled || !NSBR_COLUMN_IS_VISIBLE(column)) if (!_isTitled || !NSBR_COLUMN_IS_VISIBLE(column))
return; return;
[titleCell setControlView: self];
[titleCell setStringValue: title]; [titleCell setStringValue: title];
[titleCell drawWithFrame: aRect inView: self]; [titleCell drawWithFrame: aRect inView: self];
} }
@ -2258,6 +2259,11 @@ static NSTextFieldCell *titleCell;
- (void) dealloc - (void) dealloc
{ {
if ([titleCell controlView] == self)
{
[titleCell setControlView: nil];
}
RELEASE(_browserCellPrototype); RELEASE(_browserCellPrototype);
RELEASE(_pathSeparator); RELEASE(_pathSeparator);
RELEASE(_horizontalScroller); RELEASE(_horizontalScroller);