* fix out-of-bounds access to fFieldsPositions when drawing separator
(found by running the preflet with debug heap and guard pages) * avoid leaking of field- and field-position-arrays when fetching them via BLocale-method git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40538 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -100,7 +100,7 @@ TTimeEdit::DrawSection(uint32 index, bool hasFocus)
|
|||||||
if (!section)
|
if (!section)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fFieldPositions == NULL || index * 2 + 1 > (uint32)fFieldPosCount)
|
if (fFieldPositions == NULL || index * 2 + 1 >= (uint32)fFieldPosCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect bounds = section->Frame();
|
BRect bounds = section->Frame();
|
||||||
@@ -132,7 +132,7 @@ TTimeEdit::DrawSeparator(uint32 index)
|
|||||||
if (!section)
|
if (!section)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fFieldPositions == NULL || index * 2 + 2 > (uint32)fFieldPosCount)
|
if (fFieldPositions == NULL || index * 2 + 2 >= (uint32)fFieldPosCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BString field;
|
BString field;
|
||||||
@@ -277,8 +277,18 @@ void
|
|||||||
TTimeEdit::_UpdateFields()
|
TTimeEdit::_UpdateFields()
|
||||||
{
|
{
|
||||||
time_t time = fTime.Time_t();
|
time_t time = fTime.Time_t();
|
||||||
|
|
||||||
|
if (fFieldPositions != NULL) {
|
||||||
|
free(fFieldPositions);
|
||||||
|
fFieldPositions = NULL;
|
||||||
|
}
|
||||||
BLocale::Default()->FormatTime(&fText, fFieldPositions, fFieldPosCount,
|
BLocale::Default()->FormatTime(&fText, fFieldPositions, fFieldPosCount,
|
||||||
time, B_MEDIUM_TIME_FORMAT);
|
time, B_MEDIUM_TIME_FORMAT);
|
||||||
|
|
||||||
|
if (fFields != NULL) {
|
||||||
|
free(fFields);
|
||||||
|
fFields = NULL;
|
||||||
|
}
|
||||||
BLocale::Default()->GetTimeFields(fFields, fFieldCount,
|
BLocale::Default()->GetTimeFields(fFields, fFieldCount,
|
||||||
B_MEDIUM_TIME_FORMAT);
|
B_MEDIUM_TIME_FORMAT);
|
||||||
}
|
}
|
||||||
@@ -492,7 +502,7 @@ TDateEdit::DrawSection(uint32 index, bool hasFocus)
|
|||||||
if (!section)
|
if (!section)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fFieldPositions == NULL || index * 2 + 1 > (uint32)fFieldPosCount)
|
if (fFieldPositions == NULL || index * 2 + 1 >= (uint32)fFieldPosCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetLowColor(ViewColor());
|
SetLowColor(ViewColor());
|
||||||
@@ -525,7 +535,7 @@ TDateEdit::DrawSeparator(uint32 index)
|
|||||||
if (!section)
|
if (!section)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fFieldPositions == NULL || index * 2 + 2 > (uint32)fFieldPosCount)
|
if (fFieldPositions == NULL || index * 2 + 2 >= (uint32)fFieldPosCount)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BString field;
|
BString field;
|
||||||
@@ -677,8 +687,18 @@ void
|
|||||||
TDateEdit::_UpdateFields()
|
TDateEdit::_UpdateFields()
|
||||||
{
|
{
|
||||||
time_t time = BDateTime(fDate, BTime()).Time_t();
|
time_t time = BDateTime(fDate, BTime()).Time_t();
|
||||||
|
|
||||||
|
if (fFieldPositions != NULL) {
|
||||||
|
free(fFieldPositions);
|
||||||
|
fFieldPositions = NULL;
|
||||||
|
}
|
||||||
BLocale::Default()->FormatDate(&fText, fFieldPositions, fFieldPosCount,
|
BLocale::Default()->FormatDate(&fText, fFieldPositions, fFieldPosCount,
|
||||||
time, B_SHORT_DATE_FORMAT);
|
time, B_SHORT_DATE_FORMAT);
|
||||||
|
|
||||||
|
if (fFields != NULL) {
|
||||||
|
free(fFields);
|
||||||
|
fFields = NULL;
|
||||||
|
}
|
||||||
BLocale::Default()->GetDateFields(fFields, fFieldCount,
|
BLocale::Default()->GetDateFields(fFields, fFieldCount,
|
||||||
B_SHORT_DATE_FORMAT);
|
B_SHORT_DATE_FORMAT);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user